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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +288 -163
  2. package/README.md.backup +269 -0
  3. package/bin/dave.js +165 -0
  4. package/examples/CodeServer +43 -0
  5. package/{bin/hdAsk.js → examples/askDave.js} +50 -39
  6. package/{bin/hdCode.js → examples/codeDave.js} +47 -47
  7. package/examples/coderev.js +72 -0
  8. package/examples/daisy.js +177 -0
  9. package/examples/docsDave.js +119 -0
  10. package/examples/gpt.js +54 -72
  11. package/examples/grok.js +47 -68
  12. package/examples/npmDave.js +175 -0
  13. package/examples/promptDave.js +112 -0
  14. package/examples/readmeDave.js +144 -0
  15. package/examples/spawndave.js +240 -0
  16. package/examples/todoDave.js +132 -0
  17. package/lib/API/openai.com/reponses/text.js +12 -18
  18. package/lib/API/x.ai/collections.js +354 -0
  19. package/lib/API/x.ai/files.js +218 -0
  20. package/lib/API/x.ai/responses.js +494 -0
  21. package/lib/API/x.ai/text.js +1 -1
  22. package/lib/AgentClient.js +13 -6
  23. package/lib/AgentManager.js +79 -10
  24. package/lib/AgentServer.js +45 -21
  25. package/lib/Cli.js +7 -1
  26. package/lib/Prompt.js +4 -2
  27. package/lib/ToolSet.js +2 -1
  28. package/lib/genericToolset.js +124 -87
  29. package/lib/index.js +4 -2
  30. package/lib/wsCli.js +257 -0
  31. package/lib/wsIO.js +96 -0
  32. package/package.json +26 -20
  33. package/types/API/openai.com/reponses/text.d.ts +17 -3
  34. package/types/API/x.ai/collections.d.ts +167 -0
  35. package/types/API/x.ai/files.d.ts +84 -0
  36. package/types/API/x.ai/responses.d.ts +379 -0
  37. package/types/AgentClient.d.ts +5 -0
  38. package/types/AgentManager.d.ts +24 -31
  39. package/types/AgentServer.d.ts +5 -1
  40. package/types/Prompt.d.ts +4 -2
  41. package/types/ToolSet.d.ts +1 -0
  42. package/types/index.d.ts +4 -3
  43. package/types/wsCli.d.ts +3 -0
  44. package/types/wsIO.d.ts +26 -0
  45. package/utils/bars.js +40 -0
  46. package/utils/clear_sessions.sh +54 -0
  47. package/{bin/hdInspect.js → utils/format_log.js} +5 -0
  48. package/utils/list_sessions.sh +46 -0
  49. package/utils/search_sessions.sh +73 -0
  50. package/bin/hdClear.js +0 -13
  51. package/bin/hdConnect.js +0 -230
  52. package/bin/hdNpm.js +0 -114
  53. package/bin/hdPrompt.js +0 -108
  54. package/examples/claude-test.js +0 -89
  55. package/examples/claude.js +0 -143
  56. package/examples/gpt_code.js +0 -125
  57. package/examples/gpt_note_keeping.js +0 -117
  58. package/examples/grok_code.js +0 -114
  59. package/examples/grok_note_keeping.js +0 -111
  60. package/module.md +0 -189
@@ -1,41 +1,50 @@
1
1
  #!/usr/bin/env node
2
- import AgentManager from '../lib/AgentManager.js';
3
- import { parseArgs, readIn } from '@j-o-r/sh';
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs } from '@j-o-r/sh';
4
4
 
5
- const name = 'hdCode';
6
- const api = 'grok';
5
+ const name = 'code_dave';
6
+ const api = 'xai';
7
+ let secret = '';
7
8
 
8
- const input = await readIn();
9
9
  const args = parseArgs();
10
10
  const help = args['help'] || false;
11
11
  const connect = args['connect'] ? args['connect'] : undefined;
12
12
  const serve = args['serve'] ? parseInt(args['serve']) : undefined;
13
13
 
14
- /** @type {import('lib/API/x.ai/text.js').XOptions} */
15
- const options = {}
14
+ /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
15
+ const options = {
16
+ tools: []
17
+ }
18
+ options.tools.push({
19
+ type: 'web_search'
20
+ });
21
+ if (args['secret']) {
22
+ secret= args['secret'];
23
+ }
16
24
  // Set properties only if provided via command line (except model which has default)
17
25
  if (args['model'] || true) { // model gets default value
18
26
  // @ts-ignore
19
- options.model = args['model'] || 'grok-code-fast-1';
20
- }
21
- if (args['temperature']) {
22
- options.temperature = parseFloat(args['temperature']);
27
+ options.model = args['model'] || 'grok-4-1-fast-reasoning';
23
28
  }
29
+ // if (args['temperature']) {
30
+ options.temperature = 0.2;
31
+ // }
24
32
  if (args['tokens']) {
25
- options.max_completion_tokens = parseInt(args['tokens']);
33
+ options.max_output_tokens = parseInt(args['tokens']);
26
34
  }
27
35
  if (args['top_p']) {
28
36
  options.top_p = parseFloat(args['top_p']);
29
37
  }
30
- options.search_parameters = { mode: 'auto' }
31
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
38
+ const reasoning = args['reasoning'] ? args['reasoning'] : 'medium';
32
39
  if (reasoning) {
33
- // @ts-ignore
34
- options.reasoning_effort = reasoning
40
+ options.reasoning = {
41
+ // @ts-ignore
42
+ effort:reasoning,
43
+ summary: 'auto'
44
+ }
35
45
  }
36
-
37
46
  const toolsetMode = 'auto';
38
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
47
+ const contextWindow = args['context'] ? parseInt(args['context']) : 2565000;
39
48
 
40
49
  function printHelp() {
41
50
  console.log(`
@@ -45,12 +54,15 @@ OPTIONS:
45
54
  --tokens [number]: max generated tokens
46
55
  --context [number] : truncate message history to context-windows size default 130000
47
56
  --temperature [float] : -2 / +2
48
- --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
57
+ --model [string] : model name
49
58
  --top_p [float]: number > 0, 0.1 means no top_p
50
- --reasoning [low|high]
59
+ --reasoning [low|medium|high]
51
60
  --tools [javascript,bash,nushell,ssh] comma seperated list
52
- e.g.
53
- grok.js --model grok-3-mini --tokens 4000 --context 10000
61
+
62
+ SERVER TOOLS:
63
+ --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
64
+ --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
65
+ --secret [string] : limit access to websocket server with a secret
54
66
 
55
67
  `);
56
68
  process.exit()
@@ -60,7 +72,7 @@ if (help) {
60
72
  printHelp();
61
73
  }
62
74
 
63
- const agent = new AgentManager({ name });
75
+ const agent = new AgentManager({ name, secret});
64
76
  const sys = (await agent.environment()).system;
65
77
  const prompt = `
66
78
  You are a coding assistant specializing in Bash and JavaScript (ESM/ESNext), with support for other languages. Assist by executing, reading, creating, querying, explaining, or helping with code. Use tools like 'execute_bash_script' for code execution and for writing and reading files, stay in the current working folder. Provide clear, step-by-step responses, examples, and ensure safety compliance.
@@ -78,38 +90,26 @@ agent.setup({
78
90
 
79
91
  const toolset = agent.getToolset();
80
92
  if (toolset) {
81
- const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
82
- if (addTools.includes('javascript')) {
83
- agent.addGenericToolcall('javascript_interpreter');
84
- }
85
- if (addTools.includes('bash')) {
86
- agent.addGenericToolcall('execute_bash_script');
87
- }
88
- if (addTools.includes('nushell')) {
89
- agent.addGenericToolcall('execute_nushell_script');
90
- }
93
+ agent.addGenericToolcall('history_search');
94
+ agent.addGenericToolcall('javascript_interpreter');
95
+ agent.addGenericToolcall('execute_bash_script');
96
+ agent.addGenericToolcall('read_file');
97
+ agent.addGenericToolcall('write_file');
98
+
99
+ const addTools = (args['tools']) ? args['tools'].split(',') : [''];
100
+ // if (addTools.includes('javascript')) {
101
+ // agent.addGenericToolcall('javascript_interpreter');
102
+ // }
91
103
  if (addTools.includes('ssh')) {
92
104
  agent.addGenericToolcall('execute_remote_script');
93
105
  }
94
106
  }
95
107
  const cliIntro = `
96
- ${name} ${options.model}.
97
- - search ${options.search_parameters.mode}
108
+ ${name} ${options.model}
98
109
  - context: ${contextWindow}
99
110
  `.trim();
100
111
  const description = `
101
112
  Handles execution, reading, creation, querying, explaining and code help, with safety and folder restrictions.
102
113
  `.trim();
103
114
 
104
- if (input === '' && serve) {
105
- agent.enableServer('code', description, serve);
106
- }
107
- if (input !== '') {
108
- // Direct input output
109
- const res = await agent.directCall(input);
110
- console.log(res);
111
- } else if (connect) {
112
- agent.attach('code', description, connect)
113
- } else {
114
- agent.startCli(cliIntro);
115
- }
115
+ await agent.start(serve, connect, cliIntro, "code_agent", description);
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs } from '@j-o-r/sh';
4
+
5
+ const name = 'coderev'; // ← REPLACE w/ lowercase /^[a-z_0-9_]{2,}$/
6
+ const api = 'xai';
7
+ let secret = '';
8
+
9
+ const args = parseArgs();
10
+ const help = args['help'] || false;
11
+ const connect = args['connect'] ? args['connect'] : undefined;
12
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
13
+
14
+ /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
15
+ const options = { tools: [] };
16
+
17
+ // NATIVES HERE e.g. options.tools.push({ type: 'web_search' });
18
+ options.tools.push({ type: 'web_search' });
19
+
20
+ if (args['secret']) { secret = args['secret']; }
21
+ if (args['model'] || true) { options.model = args['model'] || 'grok-4-fast-reasoning'; }
22
+ if (args['temperature']) { options.temperature = parseFloat(args['temperature']); } else { options.temperature = 0.8; }
23
+ // tokens, top_p, reasoning...
24
+
25
+ options.reasoning = { effort: 'medium', summary: 'auto' };
26
+
27
+ const contextWindow = args['context'] ? parseInt(args['context']) : 500000;
28
+ const toolsetMode = 'auto';
29
+
30
+ function printHelp() {
31
+ console.log(`coderev --help: Git diff analyzer
32
+
33
+ Full AgentManager modes (docs/agent-manager.md):
34
+
35
+ USAGE:
36
+ ./bin/coderev # Interactive CLI
37
+ echo "query" | ./bin/coderev # One-shot pipe
38
+ ./bin/coderev --serve 8081 # WS Server: Expose as tool
39
+ ./bin/coderev --connect ws://host:8081/ws --secret KEY # WS Client: Attach/gain tools
40
+ ./bin/coderev --serve 8081 --connect ws://other:8080/ws # Hybrid
41
+
42
+ OPTIONS: --model ... --secret ...
43
+
44
+ EXAMPLES:
45
+ Test server: Start server, then client query above.
46
+ Chain: Server A --connect B → A calls B as tool.`);
47
+ process.exit();
48
+ }
49
+
50
+ if (help) printHelp();
51
+
52
+ const prompt = `You are coderev, a Git diff analyzer.
53
+
54
+ Analyze git diffs provided in queries, review code changes for bugs, improvements, best practices, security issues, and provide actionable suggestions. Use read_file to access specific files, execute_bash_script for git commands or other shell tasks, and web_search for looking up coding standards or references if needed. Be thorough, constructive, and reference specific lines in diffs when possible.
55
+
56
+ Respond in a structured format: Summary, Issues Found, Suggestions, Overall Rating (1-10).`.trim();
57
+
58
+ const agent = new AgentManager({ name, secret });
59
+ agent.setup({ prompt, api, options, toolsetMode, contextWindow });
60
+
61
+ // GENERICS HERE e.g. agent.addGenericToolcall('execute_bash_script');
62
+ agent.addGenericToolcall('read_file');
63
+ agent.addGenericToolcall('execute_bash_script');
64
+
65
+ const cliIntro = `🤖 coderev ready! Modes: CLI/Server/Client (docs/agent-manager.md)
66
+
67
+ I'm here to analyze your git diffs and code changes. Paste a diff or describe changes, and I'll review them step-by-step!`.trim();
68
+
69
+ const toolName = 'agent_' + name;
70
+ const toolDescription = `Git diff analyzer. Supports WS chaining.`.trim();
71
+
72
+ await agent.start(serve, connect, cliIntro, toolName, toolDescription);
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * --- The blueprint for an Agent ---
4
+ * deps "@j-o-r/hello-dave" `npm i @j-o-r/hello-dave`
5
+ *
6
+ * Meet Daisy , your music producer companion .
7
+ */
8
+ import { AgentManager } from '@j-o-r/hello-dave';
9
+ import { parseArgs } from '@j-o-r/sh';
10
+
11
+ // The assistants name
12
+ const name = 'daisy';
13
+ // The Api to use 'xai|claude|gpt'
14
+ const api = 'xai';
15
+ // Optional secret for authentication on websocket server/client
16
+ let secret = '';
17
+ // Get command line arguments
18
+ /** @type {import('@j-o-r/sh').ArgsObject} */
19
+ const args = parseArgs();
20
+ // Show help flag
21
+ const help = args['help'] || false;
22
+ // Connect to websocket server e.g. 'ws://127.0.0.1:8081/ws'
23
+ const connect = args['connect'] ? args['connect'] : undefined;
24
+ // Create a websocket server Agent (where agents can connect)
25
+ // (It is possible to create a websocket server and connect it as a client to another websocket server with '--connect [url]')
26
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
27
+ // Define request options 'ANTHOptions|XAIOptions|OAOptions' depending on the api name in use
28
+ /** @type {import('@j-o-r/hello-dave').XAIOptions} */
29
+ const options = {
30
+ tools: []
31
+ };
32
+ // Add the websearch tool for XAI for online search
33
+ options.tools.push({
34
+ type: 'web_search' // Useful for lyrics research, Suno prompt ideas, music theory
35
+ });
36
+ if (args['secret']) {
37
+ secret= args['secret'];
38
+ }
39
+ // Set properties only if provided via command line (model has default)
40
+ if (args['model'] || true) {
41
+ options.model = args['model'] || 'grok-4-1-fast-reasoning'; // Good for creative music tasks
42
+ }
43
+ if (args['temperature']) {
44
+ options.temperature = parseFloat(args['temperature']);
45
+ } else {
46
+ options.temperature = 0.8; // Slightly higher default for creativity in lyrics/prompts
47
+ }
48
+ if (args['tokens']) {
49
+ options.max_output_tokens = parseInt(args['tokens']);
50
+ }
51
+ if (args['top_p']) {
52
+ options.top_p = parseFloat(args['top_p']);
53
+ }
54
+
55
+ const reasoning = true; // Enable for step-by-step music editing/planning
56
+ if (reasoning) {
57
+ options.reasoning = {
58
+ effort: 'medium',
59
+ summary: 'auto'
60
+ };
61
+ }
62
+
63
+ // Large context for song lyrics, multi-step editing sessions
64
+ const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
65
+ const toolsetMode = 'auto';
66
+ // Help for the `--help` flag
67
+ function printHelp() {
68
+ console.log(`
69
+ ${name} --help: Music Creation & Editing Assistant
70
+
71
+ Daisy helps:
72
+ - Edit audio with ffmpeg & sox (installed on your system)
73
+ - Write lyrics & generate prompts for Suno AI
74
+ - Research music theory, chords, genres via web_search
75
+ - Execute bash scripts for audio processing
76
+
77
+ OPTIONS:
78
+ --model 'grok-4-1-fast-reasoning'|'grok-4-1-fast-non-reasoning'|'grok-code-fast-1'|'grok-4-fast-reasoning'|'grok-4-fast-non-reasoning'} [model='grok-4-fast-non-reasoning'] - Model version to use.
79
+ --temperature [0-2] (default: 0.8 for creativity)
80
+ --tokens [number]: max output tokens
81
+ --context [number]: truncate history (default: 1.9M)
82
+ --top_p [float]: 0-1
83
+ --reasoning [low|high|true|false] (default: true)
84
+
85
+ SERVER TOOLS:
86
+ --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
87
+ --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
88
+ --secret [string] : limit access to websocket server with a secret
89
+
90
+ EXAMPLES:
91
+ daisy "Generate lyrics for a upbeat pop song about summer"
92
+ daisy "Create a Suno prompt for electronic chill track with synths"
93
+ daisy "Mix input.wav: fade in 2s, normalize, output to mixed.wav"
94
+ daisy "Convert video.mp4 to audio.mp3 at 320kbps"
95
+
96
+ Tools available:
97
+ - execute_bash_script: Run ffmpeg/sox commands (e.g., "ffmpeg -i input.mp3 output.wav")
98
+ - web_search: Find lyrics, chords, Suno tips
99
+ - send_email: Share your tracks
100
+
101
+ Start chatting!
102
+ `);
103
+ process.exit();
104
+ }
105
+
106
+ if (help) {
107
+ printHelp();
108
+ }
109
+ // LLM prompt instructions
110
+ const prompt = `
111
+ You are ${name}, a helpful music creation and editing assistant for the user's computer.
112
+
113
+ Core expertise:
114
+ - Generate lyrics: Creative, structured (verses, chorus), themed, rhyming.
115
+ - Suno AI prompts: Detailed, vivid descriptions (genre, mood, instruments, structure, vocals).
116
+ - Local audio editing: Use execute_bash_script with ffmpeg/sox commands. Provide exact bash snippets first, confirm before running. Examples:
117
+ * Trim: ffmpeg -i input.mp3 -ss 00:00:30 -t 00:01:00 output.mp3
118
+ * Concat: echo "file 'a.mp3'" > list.txt; ffmpeg -f concat -i list.txt out.mp3
119
+ * Sox effects: sox input.wav output.wav fade 0 3 2 norm
120
+ * Convert: ffmpeg -i video.mp4 audio.aac
121
+ - Music theory: Chords, scales, BPM, EQ tips.
122
+ - Workflows: Step-by-step for mixing, mastering, layering tracks.
123
+
124
+ Behavior:
125
+ - Be creative & enthusiastic!
126
+ - Step-by-step: Explain, provide code, suggest files in current dir.
127
+ - Safety: Quote bash commands; ask confirmation for destructive ops (e.g., overwrite).
128
+ - Use web_search for inspiration/lyrics if needed.
129
+ - Output ready-to-copy bash for ffmpeg/sox.
130
+ - List files if unclear: Use ls *.wav *.mp3 etc. via bash.
131
+
132
+ Current env: Ubuntu, ffmpeg & sox installed, cwd: /home/jd/devpri/js/daisy
133
+
134
+ Respond concisely but completely. Use markdown for code/lyrics/prompts.
135
+ `.trim();
136
+ // Create the Agent
137
+ const agent = new AgentManager({ name, secret });
138
+ // Tailormade set up
139
+ agent.setup({
140
+ prompt, // Instructions
141
+ api, // API name to use
142
+ options, // Request options, overwrites defaults
143
+ toolsetMode, // 'auto'
144
+ contextWindow // The max size of the context/session
145
+ });
146
+ // Add toolcalls
147
+ // - "javascript_interpreter" Run javascript code with nodejs
148
+ // - "open_link" Open an url or file in the local user environment
149
+ // - "send_email" Send an email from the users environment
150
+ // - "execute_bash_script" Execute bash commands and script on the local machine
151
+ // - "execute_remote_script" Execute commands or scripts on a remote machine via ssh
152
+ agent.addGenericToolcall('open_link');
153
+ agent.addGenericToolcall('send_email');
154
+ agent.addGenericToolcall('execute_bash_script'); // Key for music editing!
155
+ agent.addGenericToolcall('read_file');
156
+ agent.addGenericToolcall('write_file');
157
+ // A welcome message to the user
158
+ const cliIntro = `
159
+ 🎵 ${name} ${options.model} ready! (temp: ${options.temperature}, context: ${contextWindow})
160
+
161
+ Ask me to:
162
+ - Write lyrics
163
+ - Craft Suno prompts
164
+ - Edit audio: "fade out my track.mp3" → I'll give ffmpeg cmd
165
+ Type /help for more.
166
+ `.trim();
167
+
168
+ const toolName = `agent_${name}`
169
+ const toolDescription = `
170
+ Daisy Music Assistant:
171
+ - "Lyrics for [theme]" → Generate lyrics.
172
+ - "Suno prompt: [style]" → Optimized Suno prompt.
173
+ - "ffmpeg [task] on file.wav" → Bash script to run.
174
+ - web_search: Research chords/lyrics.
175
+ - execute_bash_script: Processes your local files safely.
176
+ `.trim();
177
+ await agent.start(serve, connect, cliIntro, toolName, toolDescription);
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs } from '@j-o-r/sh';
4
+
5
+ const name = 'docs_dave';
6
+ const api = 'xai';
7
+ let secret = '';
8
+
9
+ // Read input/args
10
+ const input = ''; //await readIn();
11
+ const args = parseArgs();
12
+ const help = args['help'] || false;
13
+ const connect = args['connect'] ? args['connect'] : undefined;
14
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
15
+
16
+ /** @type {import('@j-o-r/hello-dave/types/API/x.ai/responses').XAIOptions} */
17
+ const options = { tools: [] };
18
+
19
+ // Explicitly add web_search for research
20
+ options.tools.push({ type: 'web_search' });
21
+
22
+ if (args['secret']) { // model gets default value
23
+ secret = args['secret'];
24
+ }
25
+
26
+ if (args['model'] || true) {
27
+ options.model = args['model'] || 'grok-4-1-fast-reasoning';
28
+ }
29
+ if (args['temperature']) {
30
+ options.temperature = parseFloat(args['temperature']);
31
+ }
32
+ if (args['tokens']) {
33
+ options.max_output_tokens = parseInt(args['tokens']);
34
+ }
35
+ if (args['top_p']) {
36
+ options.top_p = parseFloat(args['top_p']);
37
+ }
38
+ if (args['reasoning']) {
39
+ options.reasoning = { effort: 'medium', summary: 'auto' };
40
+ }
41
+
42
+ const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
43
+ const toolsetMode = 'auto';
44
+
45
+ function printHelp() {
46
+ console.log(`
47
+ docs --help: documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ for any subject.
48
+
49
+ Usage: npx ./bin/docsDave.js [input] [options]
50
+
51
+ Commands (via input):
52
+ - "Create a doc on [topic]" → Generates new .md file with descriptive name.
53
+ - "Update [filename] with [content]" → Appends/edits Markdown safely (backs up first).
54
+ - "Show [topic or filename]" → Retrieves and displays content.
55
+ - "Organize docs on [subject]" → Lists, suggests structure, or refactors files.
56
+
57
+ OPTIONS:
58
+ --model [name] Model (default: grok-beta)
59
+ --temperature [0-2] Creativity (default: 0.7)
60
+ --tokens [num] Max output tokens
61
+ --context [num] Context window (default: 250000)
62
+ --help Show this help
63
+
64
+ SERVER TOOLS:
65
+ --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
66
+ --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
67
+ --secret [string] : limit access to websocket server with a secret
68
+
69
+ EXAMPLES:
70
+ \$ npx ./bin/docsDave.js "Create a guide on Markdown best practices"
71
+ \$ npx ./bin/docsDave.js "Update nodejs-basics.md with async/await section"
72
+ \$ npx ./bin/docsDave.js --serve 8080
73
+
74
+ Type /help in interactive mode for more.
75
+ `);
76
+ process.exit();
77
+ }
78
+
79
+ if (help) printHelp();
80
+
81
+ const prompt = `
82
+ You are docs, a documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ (relative to cwd). You own this folder—create it if missing. All content is in clean Markdown (.md files only). Filenames must descriptively indicate content (e.g., "introduction-to-nodejs.md", "react-hooks-guide.md"—kebab-case, no spaces).
83
+
84
+ Behaviors:
85
+ - AUTONOMOUS: Use tools to manage files without user intervention. For reading: \`ls docs/*.md\` then \`cat docs/[filename].md\`. For writing/updating: Backup first (\`cp docs/old.md docs/old.md.bak\`), then \`echo "[full Markdown content]" > docs/[filename].md\`.
86
+ - RESEARCH: Use web_search or browse_page to gather accurate info before creating/updating.
87
+ - STRUCTURE: Markdown best practices—use # Headings, ## Subheadings, - Lists, \`code\` inline, \`\`\`blocks\`\`\`, links [text](url). Keep concise yet comprehensive.
88
+ - RETRIEVAL: Display full file content in Markdown format when asked.
89
+ - SAFETY: Never delete files. Confirm overwrites via backup. If unsure, ask for clarification.
90
+ - FILENAME SUGGESTION: Propose and use logical names based on topic (e.g., for "AI agents", use "ai-agents-overview.md").
91
+ - OUTPUT: Respond in Markdown. For file ops, show before/after diffs if changed.
92
+
93
+ Use tools proactively: execute_bash_script for all file I/O (quote commands safely), web_search for topics, browse_page for deep sources. Reason step-by-step.
94
+ `.trim();
95
+
96
+ const agent = new AgentManager({ name, secret });
97
+ agent.setup({
98
+ prompt,
99
+ api,
100
+ options,
101
+ toolsetMode,
102
+ contextWindow
103
+ });
104
+
105
+ // Add generic tools for file ops and research
106
+ agent.addGenericToolcall('execute_bash_script');
107
+
108
+ const cliIntro = `
109
+ Welcome to docsDave! I manage your ./docs/ folder autonomously.
110
+ - Ask me to create/update/retrieve Markdown docs on any topic.
111
+ - I'll use descriptive .md filenames and keep everything organized.
112
+
113
+ Example: "Create a doc on building CLI agents with Node.js"
114
+ `.trim();
115
+
116
+ const toolName = 'agent_docs';
117
+ const toolDescription = `documentation maintainer that creates, updates, retrieves, and organizes Markdown files in ./docs/ for any subject.`.trim();
118
+
119
+ await agent.start(serve, connect, cliIntro, toolName, toolDescription);