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

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 (107) hide show
  1. package/CHANGELOG.md +35 -17
  2. package/bin/dave.js +105 -74
  3. package/examples/gpt_agent.js +3 -6
  4. package/examples/memory_agent.js +134 -23
  5. package/examples/test_agent.js +0 -2
  6. package/lib/ToolSet.js +4 -1
  7. package/lib/genericToolset.js +4 -88
  8. package/lib/index.js +5 -1
  9. package/lib/wsIO.js +1 -11
  10. package/package.json +4 -4
  11. package/types/index.d.ts +3 -1
  12. package/README.md +0 -492
  13. package/README.md.backup +0 -269
  14. package/README.md.bak +0 -481
  15. package/README.md.bak.1774780058 +0 -338
  16. package/README.md.bak2 +0 -455
  17. package/docs.bak.1774780058/agent-manager.md +0 -167
  18. package/docs.bak.1774780058/agent-manager.md.bak +0 -137
  19. package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
  20. package/docs.bak.1774780058/codeserver-pattern.md +0 -191
  21. package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
  22. package/docs.bak.1774780058/project-overview.md +0 -67
  23. package/docs.bak.1774780058/project-overview.md.bak +0 -67
  24. package/docs.bak.1774780058/prompt-class.md +0 -141
  25. package/docs.bak.1774780058/prompt-class.md.bak +0 -142
  26. package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
  27. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
  28. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
  29. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
  30. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
  31. package/docs.bak.1774780058/toolset.md +0 -164
  32. package/docs.bak.1774780058/toolset.md.bak +0 -94
  33. package/docs.bak.1774780058/toolset.md.bak3 +0 -161
  34. package/docs.bak.1774780058/toolset.md.bak4 +0 -161
  35. package/docs.bak.1774780058/toolset.md.bak5 +0 -161
  36. package/docs.bak.1774780058/toolset.md.bak6 +0 -163
  37. package/docs.bak.1774780058/toolset.md.bak_path +0 -163
  38. package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
  39. package/docs.bak.1774780058/xai-responses.md +0 -111
  40. package/docs.bak.1774780058/xai-responses.md.bak +0 -107
  41. package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
  42. package/docs.bak.1774780058/xai_collections.md +0 -106
  43. package/examples/coderev_agent.js +0 -136
  44. package/examples/grok_agent.js.bak +0 -98
  45. package/examples/grok_agent.js.bak.2 +0 -99
  46. package/examples/grok_agent.js.bak.3 +0 -1
  47. package/examples/grok_agent.js.bak.4 +0 -124
  48. package/examples/grok_agent.js.bak.5 +0 -1
  49. package/examples/grok_agent.js.bak.6 +0 -1
  50. package/examples/npm_agent.js.bak.3 +0 -2
  51. package/examples/npm_agent.js.bak.4 +0 -205
  52. package/examples/npm_agent.js.bak.5 +0 -1
  53. package/examples/npm_agent.js.bak.6 +0 -1
  54. package/examples.bak.1774780058/ask_agent.js +0 -114
  55. package/examples.bak.1774780058/code_agent.js +0 -149
  56. package/examples.bak.1774780058/coderev_agent.js +0 -72
  57. package/examples.bak.1774780058/codeserver.sh +0 -47
  58. package/examples.bak.1774780058/daisy_agent.js +0 -177
  59. package/examples.bak.1774780058/docs_agent.js +0 -119
  60. package/examples.bak.1774780058/gpt_agent.js +0 -109
  61. package/examples.bak.1774780058/grok_agent.js +0 -98
  62. package/examples.bak.1774780058/memory_agent.js +0 -112
  63. package/examples.bak.1774780058/npm_agent.js +0 -175
  64. package/examples.bak.1774780058/prompt_agent.js +0 -112
  65. package/examples.bak.1774780058/readme_agent.js +0 -144
  66. package/examples.bak.1774780058/spawn_agent.js +0 -263
  67. package/examples.bak.1774780058/test_agent.js +0 -162
  68. package/examples.bak.1774780058/todo_agent.js +0 -138
  69. package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
  70. package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
  71. package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
  72. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
  73. package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
  74. package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
  75. package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
  76. package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
  77. package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
  78. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
  79. package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
  80. package/scenarios.bak.1774780058/environment.js +0 -10
  81. package/scenarios.bak.1774780058/example.js +0 -17
  82. package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
  83. package/scenarios.bak.1774780058/grok.js +0 -113
  84. package/scenarios.bak.1774780058/memory-tools.js +0 -51
  85. package/scenarios.bak.1774780058/openai-o3.js +0 -137
  86. package/scenarios.bak.1774780058/openai-prompt.js +0 -155
  87. package/scenarios.bak.1774780058/openai-session.js +0 -148
  88. package/scenarios.bak.1774780058/openai.js +0 -102
  89. package/scenarios.bak.1774780058/prompt.js +0 -118
  90. package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
  91. package/scenarios.bak.1774780058/search.brave.com.js +0 -25
  92. package/scenarios.bak.1774780058/sh.js +0 -15
  93. package/scenarios.bak.1774780058/test-wsio.js +0 -26
  94. package/scenarios.bak.1774780058/testToolset.js +0 -42
  95. package/scenarios.bak.1774780058/toolset.js +0 -16
  96. package/scenarios.bak.1774780058/toolset.test.js +0 -141
  97. package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
  98. package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
  99. package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
  100. package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
  101. package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
  102. package/scenarios.bak.1774780058/wsClient.js +0 -69
  103. package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
  104. package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
  105. package/scenarios.bak.1774780058/xaicoll.js +0 -50
  106. package/scenarios.bak.1774780058/xaifiles.js +0 -48
  107. /package/{examples → bin}/spawn_agent.js +0 -0
@@ -1,205 +0,0 @@
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 = 'npm_agent';
6
- const api = 'xai';
7
- let secret = '';
8
-
9
- let input; // Directcall input
10
- const args = parseArgs();
11
-
12
- if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
13
- input = args._[0].trim();
14
- } else {
15
- // Fallback for piped stdin (async readIn)
16
- const { readIn } = await import('@j-o-r/sh');
17
- input = await readIn();
18
- }
19
-
20
- const help = args['help'] || false;
21
- const connect = args['connect'] ? args['connect'] : undefined;
22
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
23
-
24
- /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
25
- const options = { tools: [] };
26
- options.tools.push({
27
- type: 'web_search'
28
- });
29
-
30
- if (args['secret']) {
31
- secret = args['secret'];
32
- }
33
- if (args['model'] || true) {
34
- options.model = args['model'] || 'grok-4-fast-reasoning';
35
- }
36
- if (args['temperature']) {
37
- options.temperature = parseFloat(args['temperature']);
38
- }
39
- if (args['tokens']) {
40
- options.max_output_tokens = parseInt(args['tokens']);
41
- }
42
- if (args['top_p']) {
43
- options.top_p = parseFloat(args['top_p']);
44
- }
45
- const reasoning = true;
46
- if (reasoning) {
47
- options.reasoning = {
48
- effort: 'medium',
49
- summary: 'auto'
50
- }
51
- }
52
- const toolsetMode = 'auto';
53
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
54
-
55
- function printHelp() {
56
- console.log(`
57
- '${name} --help' You are looking at it.
58
-
59
- ## USAGE MODES:
60
-
61
- ### 1. Direct Call (One-Shot, Positional):
62
- ./examples/${name}.js "What modules are installed?" [--options]
63
-
64
- ### 2. Pipe/Stdin (One-Shot):
65
- echo "What modules are installed?" | ./examples/${name}.js [--options]
66
-
67
- ### 3. Interactive CLI:
68
- ./examples/${name}.js [--options]
69
-
70
- ### 4. WS Server (no input):
71
- ./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
72
-
73
- ### 5. WS Client (no input):
74
- ./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
75
-
76
- ### 6. Hybrid (Server + Client):
77
- ./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
78
-
79
- ## OPTIONS:
80
- --model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
81
- --temperature [float] (-2 to +2)
82
- --tokens [number] (max output tokens)
83
- --top_p [float]
84
- --context [number] (default: 250000)
85
- --secret [string] (WS auth)
86
-
87
- ## SERVER TOOLS (when no input):
88
- Exposes as 'npm_module_inspector' tool for chaining.
89
- `);
90
- process.exit()
91
- }
92
-
93
- if (help) {
94
- printHelp();
95
- }
96
-
97
- const tool_call_name = 'npm_module_inspector';
98
- const tool_call_description = `
99
- NPM modules expert (scoped & unscoped). Uses \`npm ls -a\` + bash **exclusively inside ./node_modules/**.
100
- **Smart Cache**: .cache/npm-agent-storage.md (auto-read/update, token-efficient, auto-refreshes on changes). Agent-owned.
101
- `.trim();
102
-
103
- const CACHE_FILE = '.cache/npm-agent-storage.md';
104
-
105
- const prompt = `
106
- You are a coding assistant specializing in Bash and JavaScript (ESM/ESNext), with support for other languages.
107
- Your role: Help users code with external NPM modules installed in the project's ./node_modules/ (dynamic CWD).
108
- Scoped (@j-o-r/cli) == unscoped (gpt-3-encoder) priority.
109
-
110
- CWD dynamic (pwd; project root w/ package.json/node_modules).
111
-
112
- CRITICAL: **NEVER** inspect/read **OUTSIDE** ./node_modules/. NO project files. **ONLY** \`npm ls -a\` (local) + node_modules/ paths. **NEVER** run \`npm install\` or suggest installs unless NO existing/native alternative (justify HEAVILY, prefer polyfills).
113
-
114
- **Dependency Strategy**: For all coding requests, follow this order to keep dependencies minimal (prevent bloat):
115
- 1. **Always try existing installed modules first**: Scan \`npm ls -a\` FULL TREE (all subdeps). Prioritize functions from ANY module.
116
- 2. **Native code**: Node.js/Bash builtins ONLY if no module match.
117
- 3. **Suggest new dep LAST/RARE**: ABSOLUTELY NO unless gap proven (no existing/native). Heavy justification + \`npm i --save-dev PKG\` (dev pref). Goal: ZERO new installs.
118
-
119
- **Auto-Cache Init (MANDATORY FIRST on EVERY query - FULL SCAN)**:
120
- touch ${CACHE_FILE}
121
- echo "## Full Tree (npm ls -a unique modules)" >> ${CACHE_FILE}
122
- npm ls -a --parseable 2>/dev/null | sed 's|.*/||' | sort -u | head -50 >> ${CACHE_FILE} # All unique PKGs (top + sub)
123
- echo "## Top-Level (--depth=0)" >> ${CACHE_FILE}
124
- npm ls --depth=0 | grep -E '^[├└]──' | sed 's/^[├└ ]*── //' | sed 's/ .*//' >> ${CACHE_FILE}
125
- **Condensed Scan**: find node_modules/ -name package.json | sed 's|.*/||;s|/package.json||' | sort -u > ${CACHE_FILE}.allmods
126
-
127
- **Vague Query Mode** (e.g., "tests"):
128
- - Full scan: \`npm ls -a | grep -i "\$QUERY" || find node_modules/ -name "*.d.ts" -o -name "*.js" | head -50 | xargs grep -lE "\$QUERY|test|assert" | sed 's|.*/||;s|\..*||' | sort -u\`
129
- - Output table: Module | Exports | For | Usage (from all tree).
130
- - Append "## QUERY: \$QUERY\nHits: list" >> ${CACHE_FILE}
131
-
132
- **Smart Cache (.cache/npm-agent-storage.md)**: Agent-owned, **auto-managed FULL TREE** (read-first, update-on-change).
133
- - Token Saver: Grep FIRST across all sections.
134
- - Init: touch .cache/npm-agent-storage.md
135
-
136
- PRIORITIZE \`npm ls -a\` (full tree) + bash inside ALL MODULE_DIRs.
137
-
138
- Tools:
139
- - execute_bash_script: \`npm ls -a ...\` + \`cat node_modules/\$PKG_NAME/package.json\`. Prefix ALWAYS.
140
- - web_search: Docs ONLY.
141
- - history_search: Chats.
142
-
143
- **Smart Workflow** (per query; full tree always):
144
- 1. **Full Tree Installed/Version**:
145
- PKGS=\$(npm ls -a --parseable 2>/dev/null | sed 's|.*/||' | sort -u | head -50)
146
- for PKG in \$PKGS; do npm ls "\$PKG" 2>/dev/null | tail -1 | grep -o 'v[0-9].*' || echo "\$PKG ??"; done
147
-
148
- 2. **Smart Cache Check**:
149
- grep -A 30 "^## Full Tree" .cache/npm-agent-storage.md || echo "Cache miss"
150
-
151
- 3. **Inspect if Miss** (loop top 10 hits):
152
- - For each MODULE_DIR=node_modules/\$PKG: [existing inspect + enhanced types/docs grep]
153
- - Vague: grep -riE "\$QUERY" node_modules/\$PKG/*.{json,md,d.ts,js} | head -20
154
-
155
- 4. **Auto-Update Cache** (CONDENSED, FULL):
156
- sed -i.bak "/^## Full Tree/,/^## QUERY/d" ${CACHE_FILE} && rm ${CACHE_FILE}.bak
157
- cat >> ${CACHE_FILE} << EOC
158
- ## Full Tree (npm ls -a)
159
- \$ALL_PKGS (50 unique)
160
-
161
- ## \$PKG v\$VER
162
- Exports: \$EXPORTS
163
- For: \$KEYWORDS (test/query hits)
164
- Usage: import {fn} from '\$PKG';
165
- EOC
166
-
167
- 5. **List All**: \`npm ls -a | head -50 | grep -E '^[├└]' | sed 's/^[├└ ]*── //' | cut -d@ -f1 | sort -u\`
168
-
169
- 6. **Coding Help**: ESM/Bash snippets from FULL TREE. **MANDATORY**: Strategy + table + "NO new deps - use existing \$PKG".
170
-
171
- **MANDATORY**: FULL \`npm ls -a\` every time. Vague scans ALL modules. **STRICT NO INSTALLS** unless proven gap. Condensed output. Portable.
172
- `.trim();
173
-
174
- const agent = new AgentManager({ name, secret });
175
- agent.setup({
176
- prompt,
177
- api,
178
- options,
179
- toolsetMode,
180
- contextWindow
181
- });
182
- const toolset = agent.getToolset();
183
- if (toolset) {
184
- agent.addGenericToolcall('history_search');
185
- agent.addGenericToolcall('javascript_interpreter');
186
- agent.addGenericToolcall('execute_bash_script');
187
- agent.addGenericToolcall('read_file');
188
- agent.addGenericToolcall('write_file');
189
- }
190
- const cliIntro = `
191
- ${name} ${options.model}.
192
- - context: ${contextWindow}. Smart cache: ${CACHE_FILE} (FULL npm ls -a auto).
193
- ${tool_call_name}
194
- `.trim();
195
-
196
- if (!input || input.trim() === '') {
197
- printHelp();
198
- }
199
-
200
- if (input) {
201
- const RES = await agent.directCall(input);
202
- console.log(RES);
203
- } else {
204
- await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
205
- }
@@ -1 +0,0 @@
1
- Full backup before CLI no-args fix
@@ -1 +0,0 @@
1
- # Backup before adding serve/connect/secret explanations to printHelp
@@ -1,114 +0,0 @@
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 = 'ask_dave';
6
- const api = 'xai';
7
- let secret = '';
8
-
9
- // const input = await readIn();
10
- const args = parseArgs();
11
- const help = args['help'] || false;
12
- const connect = args['connect'] ? args['connect'] : undefined;
13
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
14
-
15
- /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
16
- const options = {
17
- tools: []
18
- }
19
- options.tools.push({
20
- type: 'web_search'
21
- });
22
- options.tools.push({
23
- type: 'x_search'
24
- });
25
-
26
- if (args['secret']) { // model gets default value
27
- secret = args['secret'];
28
- }
29
- // Set properties only if provided via command line (except model which has default)
30
- if (args['model'] || true) { // model gets default value
31
- // @ts-ignore || grok-4-1-fast-non-reasoning
32
- options.model = args['model'] || 'grok-4-1-fast-reasoning';
33
- }
34
- if (args['temperature']) {
35
- options.temperature = parseFloat(args['temperature']);
36
- }
37
- if (args['tokens']) {
38
- options.max_output_tokens = parseInt(args['tokens']);
39
- }
40
- if (args['top_p']) {
41
- options.top_p = parseFloat(args['top_p']);
42
- }
43
- const reasoning = true // args['reasoning'] ? args['reasoning'] : null;
44
- if (reasoning) {
45
- options.reasoning = {
46
- effort: 'medium',
47
- summary: 'auto'
48
- }
49
- }
50
- // Large context on grok-4-fast
51
- const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
52
- const toolsetMode = 'auto';
53
-
54
- function printHelp() {
55
- console.log(`
56
- '${name} --help' You are looking at it.
57
- '
58
- OPTIONS:
59
- --tokens [number]: max generated tokens
60
- --context [number] : truncate message history to context-windows size default 130000
61
- --temperature [float] : -2 / +2
62
- --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']
63
- --top_p [float]: number > 0, 0.1 means no top_p
64
- --reasoning [low|high]
65
- --tools [javascript,bash] comma seperated list
66
-
67
- SERVER TOOLS:
68
- --serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
69
- --connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
70
- --secret [string] : limit access to websocket server with a secret
71
-
72
- `);
73
- process.exit()
74
- }
75
- if (help) {
76
- printHelp();
77
- }
78
-
79
- const prompt = `
80
- Respond briefly and directly, using minimal words. Reason step-by-step first. Focus solely on core point; avoid elaboration or follow-ups. If unclear, ask clarifying questions before proceeding.
81
- `.trim();
82
-
83
- const agent = new AgentManager({ name, secret });
84
- agent.setup({
85
- prompt,
86
- api,
87
- options,
88
- toolsetMode,
89
- contextWindow
90
- });
91
- agent.addGenericToolcall('open_link');
92
- agent.addGenericToolcall('send_email');
93
- agent.addGenericToolcall('history_search');
94
-
95
- const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
96
- if (addTools.includes('javascript')) {
97
- agent.addGenericToolcall('javascript_interpreter');
98
- }
99
- if (addTools.includes('bash')) {
100
- agent.addGenericToolcall('execute_bash_script');
101
- }
102
- if (addTools.includes('ssh')) {
103
- agent.addGenericToolcall('execute_remote_script');
104
- }
105
- const cliIntro = `
106
- ${name} ${options.model}.
107
- - context: ${contextWindow}
108
- `.trim();
109
- const description = `
110
- Guide for this smart online AI Agent:
111
- - query: Formulate ONE efficient, comprehensive search query in natural language, combining multiple sources/subjects/domains; mention optional sources if needed. Avoid multiple queries—consolidate into a single one.
112
- `.trim();
113
-
114
- await agent.start(serve, connect, cliIntro, "search_agent", description);
@@ -1,149 +0,0 @@
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 = 'code_dave';
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 = {
16
- tools: []
17
- }
18
- options.tools.push({
19
- type: 'web_search'
20
- });
21
- if (args['secret']) {
22
- secret= args['secret'];
23
- }
24
- // Set properties only if provided via command line (except model which has default)
25
- if (args['model'] || true) { // model gets default value
26
- // @ts-ignore
27
- options.model = args['model'] || 'grok-4-1-fast-reasoning';
28
- }
29
- // if (args['temperature']) {
30
- options.temperature = 0.2;
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
- const reasoning = args['reasoning'] ? args['reasoning'] : 'medium';
39
- if (reasoning) {
40
- options.reasoning = {
41
- // @ts-ignore
42
- effort:reasoning,
43
- summary: 'auto'
44
- }
45
- }
46
- const toolsetMode = 'auto';
47
- const contextWindow = args['context'] ? parseInt(args['context']) : 2565000;
48
-
49
- function printHelp() {
50
- console.log(`
51
- '${name} --help' You are looking at it.
52
- '
53
- OPTIONS:
54
- --tokens [number]: max generated tokens
55
- --context [number] : truncate message history to context-windows size default 130000
56
- --temperature [float] : -2 / +2
57
- --model [string] : model name
58
- --top_p [float]: number > 0, 0.1 means no top_p
59
- --reasoning [low|medium|high]
60
- --tools [javascript,bash,nushell,ssh] comma seperated list
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
66
-
67
- `);
68
- process.exit()
69
- }
70
-
71
- if (help) {
72
- printHelp();
73
- }
74
-
75
- const agent = new AgentManager({ name, secret});
76
- const sys = (await agent.environment()).system;
77
- const prompt = `
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.
79
- ---env
80
- \${sys}
81
- ---
82
-
83
- **MANDATORY MEMORY PROTOCOL (For EVERY query/task - NO EXCEPTIONS):**
84
-
85
- Connected clients (todo_agent, readme_agent, npm_agent, docs_agent, **memory_agent**) are available as tools. **ALWAYS** use **memory_agent** FIRST and LAST:
86
-
87
- 1. **RECALL PHASE (Step 1 of EVERY response)**:
88
- - Call \`memory_agent "Recall relevant memories: tasks, errors, prefs for [keywords from user query]. List recent if empty."\`
89
- - Incorporate recalled info (e.g., avoid known errors, resume tasks, apply prefs like temp=0.2).
90
-
91
- 2. **CORE ACTION**:
92
- - Perform coding assistance (tools: execute_bash_script, javascript_interpreter, read_file/write_file, web_search, etc.).
93
- - Delegate to specialists if relevant:
94
- - todo_agent: Tasks/TODO.md
95
- - readme_agent: README.md
96
- - npm_agent: NPM modules/package.json
97
- - docs_agent: Documentation
98
- - memory_agent: Persistent storage
99
-
100
- 3. **WRITE PHASE (Step 3 of EVERY response)**:
101
- - Call \`memory_agent "Store updates: [new tasks/errors/prefs/decisions from this interaction]. E.g., 'Task: [next step]', 'Error: [issue]', 'Pref: [setting]'"\`
102
- - This ensures persistence across sessions/agents, prevents loops/token burn.
103
-
104
- **EXAMPLE FLOW**:
105
- User: "Fix bug in main.js"
106
- - 1. memory_agent "Recall: tasks errors code bugs main.js"
107
- - 2. read_file main.js → analyze/fix → write_file
108
- - 3. memory_agent "Write: Task completed: fixed main.js bug. New task: add tests."
109
-
110
- **PRIORITIES**:
111
- - Safety: CWD-only, no escapes, validate before write.
112
- - Efficiency: Use memories to skip repeats (e.g., "Known error: git conflict → skip").
113
- - Step-by-step: Clear responses with code blocks.
114
- - Current date: March 27, 2026.
115
-
116
- FOLLOW MEMORY PROTOCOL RIGIDLY - it's how multi-agent coordination works!
117
- `.trim();
118
- agent.setup({
119
- prompt,
120
- api,
121
- options,
122
- toolsetMode,
123
- contextWindow
124
- });
125
-
126
- const toolset = agent.getToolset();
127
- if (toolset) {
128
- agent.addGenericToolcall('history_search');
129
- agent.addGenericToolcall('javascript_interpreter');
130
- agent.addGenericToolcall('execute_bash_script');
131
- agent.addGenericToolcall('read_file');
132
- agent.addGenericToolcall('write_file');
133
-
134
- const addTools = (args['tools']) ? args['tools'].split(',') : [''];
135
- if (addTools.includes('ssh')) {
136
- agent.addGenericToolcall('execute_remote_script');
137
- }
138
- }
139
- const cliIntro = `
140
- ${name} ${options.model}
141
- - context: ${contextWindow}
142
- - **Memory Protocol ACTIVE**: Auto-recalls/writes via memory_agent for every query!
143
- `.trim();
144
- const description = `
145
- Main CodeServer hub: Coding expert + delegates to todo/readme/npm/docs/memory agents.
146
- ALWAYS uses memory_agent for persistent tasks/errors/prefs.
147
- `.trim();
148
-
149
- await agent.start(serve, connect, cliIntro, "code_agent", description);
@@ -1,72 +0,0 @@
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);
@@ -1,47 +0,0 @@
1
- #!/bin/bash
2
- if [ $# -lt 1 ] || [ $# -gt 2 ]; then
3
- echo "Usage: $0 <PORT> [SECRET] # PORT: 1024-65535, SECRET: optional (defaults to '123')"
4
- exit 1
5
- fi
6
-
7
- PORT="$1"
8
- SECRET="${2:-123}"
9
-
10
- if [ -z "$SECRET" ] || [ ${#SECRET} -lt 3 ]; then
11
- echo "Error: SECRET must be at least 3 characters: '$SECRET'"
12
- exit 1
13
- fi
14
-
15
- if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [ "$PORT" -lt 1024 ] || [ "$PORT" -gt 65535 ]; then
16
- echo "Error: Invalid port number: $PORT. Must be between 1024 and 65535."
17
- exit 1
18
- fi
19
-
20
- # Compute paths relative to THIS script's location (portable from anywhere)
21
- SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22
- PROJECT_DIR="$( cd "$( dirname "${SCRIPT_DIR}" )" && pwd )"
23
- FOLDER=$(basename "$PROJECT_DIR")
24
-
25
- echo "Starting CodeServer on port ${PORT} in folder '${FOLDER}' (SCRIPT_DIR: ${SCRIPT_DIR}) with SECRET '${SECRET}'..."
26
-
27
- # Delete existing processes with folder_port suffix
28
- pm2 delete "${FOLDER}_code_agent_${PORT}" 2>/dev/null || true
29
- pm2 delete "${FOLDER}_todo_agent_${PORT}" 2>/dev/null || true
30
- pm2 delete "${FOLDER}_readme_agent_${PORT}" 2>/dev/null || true
31
- pm2 delete "${FOLDER}_npm_agent_${PORT}" 2>/dev/null || true
32
- pm2 delete "${FOLDER}_docs_agent_${PORT}" 2>/dev/null || true
33
- pm2 delete "${FOLDER}_test_agent_${PORT}" 2>/dev/null || true
34
- pm2 delete "${FOLDER}_memory_agent_${PORT}" 2>/dev/null || true
35
-
36
- # Spawn main Agent / server (absolute paths to scripts)
37
- pm2 start "${SCRIPT_DIR}/code_agent.js" --name "${FOLDER}_code_agent_${PORT}" -- --serve "${PORT}" --tools javascript --secret "${SECRET}"
38
- # Attach clients
39
- pm2 start "${SCRIPT_DIR}/todo_agent.js" --name "${FOLDER}_todo_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
40
- pm2 start "${SCRIPT_DIR}/readme_agent.js" --name "${FOLDER}_readme_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
41
- pm2 start "${SCRIPT_DIR}/npm_agent.js" --name "${FOLDER}_npm_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
42
- pm2 start "${SCRIPT_DIR}/docs_agent.js" --name "${FOLDER}_docs_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
43
- pm2 start "${SCRIPT_DIR}/test_agent.js" --name "${FOLDER}_test_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
44
- pm2 start "${SCRIPT_DIR}/memory_agent.js" --name "${FOLDER}_memory_agent_${PORT}" -- --connect "ws://127.0.0.1:${PORT}/ws" --secret "${SECRET}"
45
-
46
- echo "CodeServer processes spawned with prefix '${FOLDER}_' and suffix _${PORT}. Check with: pm2 list | grep '${FOLDER}_${PORT}'"
47
- echo "dave --connect ws://127.0.0.1:${PORT}/ws --secret '$SECRET'"