@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.
Files changed (119) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +216 -56
  3. package/README.md.bak +481 -0
  4. package/README.md.bak.1774780058 +338 -0
  5. package/README.md.bak2 +455 -0
  6. package/docs.bak.1774780058/agent-manager.md +167 -0
  7. package/docs.bak.1774780058/agent-manager.md.bak +137 -0
  8. package/docs.bak.1774780058/agent-manager.md.bak2 +157 -0
  9. package/docs.bak.1774780058/codeserver-pattern.md +191 -0
  10. package/docs.bak.1774780058/path-resolution-best-practices.md +104 -0
  11. package/docs.bak.1774780058/project-overview.md +67 -0
  12. package/docs.bak.1774780058/project-overview.md.bak +67 -0
  13. package/docs.bak.1774780058/prompt-class.md +141 -0
  14. package/docs.bak.1774780058/prompt-class.md.bak +142 -0
  15. package/docs.bak.1774780058/tools-syntax-validation.md +121 -0
  16. package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +125 -0
  17. package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +125 -0
  18. package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +106 -0
  19. package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +106 -0
  20. package/docs.bak.1774780058/toolset.md +164 -0
  21. package/docs.bak.1774780058/toolset.md.bak +94 -0
  22. package/docs.bak.1774780058/toolset.md.bak3 +161 -0
  23. package/docs.bak.1774780058/toolset.md.bak4 +161 -0
  24. package/docs.bak.1774780058/toolset.md.bak5 +161 -0
  25. package/docs.bak.1774780058/toolset.md.bak6 +163 -0
  26. package/docs.bak.1774780058/toolset.md.bak_path +163 -0
  27. package/docs.bak.1774780058/toolset.md.bak_syntax +161 -0
  28. package/docs.bak.1774780058/xai-responses.md +111 -0
  29. package/docs.bak.1774780058/xai-responses.md.bak +107 -0
  30. package/docs.bak.1774780058/xai-responses.md.bak2 +107 -0
  31. package/docs.bak.1774780058/xai_collections.md +106 -0
  32. package/examples/ask_agent.js +137 -0
  33. package/examples/code_agent.js +149 -0
  34. package/examples/coderev_agent.js +136 -0
  35. package/examples/codeserver.sh +47 -0
  36. package/examples/daisy_agent.js +170 -0
  37. package/examples/docs_agent.js +148 -0
  38. package/examples/gpt_agent.js +125 -0
  39. package/examples/grok_agent.js +132 -0
  40. package/examples/grok_agent.js.bak +98 -0
  41. package/examples/grok_agent.js.bak.2 +99 -0
  42. package/examples/grok_agent.js.bak.3 +1 -0
  43. package/examples/grok_agent.js.bak.4 +124 -0
  44. package/examples/grok_agent.js.bak.5 +1 -0
  45. package/examples/grok_agent.js.bak.6 +1 -0
  46. package/examples/memory_agent.js +152 -0
  47. package/examples/npm_agent.js +202 -0
  48. package/examples/npm_agent.js.bak.3 +2 -0
  49. package/examples/npm_agent.js.bak.4 +205 -0
  50. package/examples/npm_agent.js.bak.5 +1 -0
  51. package/examples/npm_agent.js.bak.6 +1 -0
  52. package/examples/prompt_agent.js +133 -0
  53. package/examples/readme_agent.js +148 -0
  54. package/examples/spawn_agent.js +293 -0
  55. package/examples/test_agent.js +187 -0
  56. package/examples/todo_agent.js +175 -0
  57. package/{examples/codeDave.js → examples.bak.1774780058/code_agent.js} +40 -6
  58. package/{examples/CodeServer → examples.bak.1774780058/codeserver.sh} +9 -5
  59. package/examples.bak.1774780058/memory_agent.js +112 -0
  60. package/{examples/spawndave.js → examples.bak.1774780058/spawn_agent.js} +29 -6
  61. package/examples.bak.1774780058/test_agent.js +162 -0
  62. package/{examples/todoDave.js → examples.bak.1774780058/todo_agent.js} +8 -2
  63. package/lib/API/x.ai/responses.js +7 -9
  64. package/lib/AgentManager.js +3 -2
  65. package/lib/AgentServer.js +23 -19
  66. package/lib/genericToolset.js +159 -26
  67. package/lib/genericToolset.js.bak_syntax +402 -0
  68. package/lib/wsCli.js +0 -1
  69. package/package.json +4 -5
  70. package/scenarios.bak.1774780058/data/eval_node_message.json +9 -0
  71. package/scenarios.bak.1774780058/data/hist_oa.json +66 -0
  72. package/scenarios.bak.1774780058/data/o3_response1.json +96 -0
  73. package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +112 -0
  74. package/scenarios.bak.1774780058/data/tool_oa.json +96 -0
  75. package/scenarios.bak.1774780058/data/tool_xai.json +59 -0
  76. package/scenarios.bak.1774780058/data/tool_xai2.json +40 -0
  77. package/scenarios.bak.1774780058/data/xai-response-1.json +59 -0
  78. package/scenarios.bak.1774780058/data/xai-response-2.json +10 -0
  79. package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +59 -0
  80. package/scenarios.bak.1774780058/data/xai_search_response.json +58 -0
  81. package/scenarios.bak.1774780058/environment.js +10 -0
  82. package/scenarios.bak.1774780058/example.js +17 -0
  83. package/scenarios.bak.1774780058/genericToolset.test.js +182 -0
  84. package/scenarios.bak.1774780058/grok.js +113 -0
  85. package/scenarios.bak.1774780058/memory-tools.js +51 -0
  86. package/scenarios.bak.1774780058/openai-o3.js +137 -0
  87. package/scenarios.bak.1774780058/openai-prompt.js +155 -0
  88. package/scenarios.bak.1774780058/openai-session.js +148 -0
  89. package/scenarios.bak.1774780058/openai.js +102 -0
  90. package/scenarios.bak.1774780058/prompt.js +118 -0
  91. package/scenarios.bak.1774780058/promptFishbowl.js +76 -0
  92. package/scenarios.bak.1774780058/search.brave.com.js +25 -0
  93. package/scenarios.bak.1774780058/sh.js +15 -0
  94. package/scenarios.bak.1774780058/test-wsio.js +26 -0
  95. package/scenarios.bak.1774780058/testToolset.js +42 -0
  96. package/scenarios.bak.1774780058/toolset.js +16 -0
  97. package/scenarios.bak.1774780058/toolset.test.js +141 -0
  98. package/scenarios.bak.1774780058/write_file_syntax.test.js +145 -0
  99. package/scenarios.bak.1774780058/write_file_validation/README.md +30 -0
  100. package/scenarios.bak.1774780058/write_file_validation/bad.js +3 -0
  101. package/scenarios.bak.1774780058/write_file_validation/good.js +4 -0
  102. package/scenarios.bak.1774780058/write_file_validation/test.sh +43 -0
  103. package/scenarios.bak.1774780058/wsClient.js +69 -0
  104. package/scenarios.bak.1774780058/xai_responses.integration.test.js +57 -0
  105. package/scenarios.bak.1774780058/xai_responses.test.js +154 -0
  106. package/scenarios.bak.1774780058/xaicoll.js +50 -0
  107. package/scenarios.bak.1774780058/xaifiles.js +48 -0
  108. package/types/AgentManager.d.ts +4 -3
  109. package/utils/syntax_check.sh +61 -0
  110. package/utils/test.sh +46 -0
  111. /package/{examples/askDave.js → examples.bak.1774780058/ask_agent.js} +0 -0
  112. /package/{examples/coderev.js → examples.bak.1774780058/coderev_agent.js} +0 -0
  113. /package/{examples/daisy.js → examples.bak.1774780058/daisy_agent.js} +0 -0
  114. /package/{examples/docsDave.js → examples.bak.1774780058/docs_agent.js} +0 -0
  115. /package/{examples/gpt.js → examples.bak.1774780058/gpt_agent.js} +0 -0
  116. /package/{examples/grok.js → examples.bak.1774780058/grok_agent.js} +0 -0
  117. /package/{examples/npmDave.js → examples.bak.1774780058/npm_agent.js} +0 -0
  118. /package/{examples/promptDave.js → examples.bak.1774780058/prompt_agent.js} +0 -0
  119. /package/{examples/readmeDave.js → examples.bak.1774780058/readme_agent.js} +0 -0
@@ -0,0 +1,205 @@
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
+ }
@@ -0,0 +1 @@
1
+ Full backup before CLI no-args fix
@@ -0,0 +1 @@
1
+ # Backup before adding serve/connect/secret explanations to printHelp
@@ -0,0 +1,133 @@
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 = 'prompt_agent';
6
+ const api = 'xai';
7
+ let secret = '';
8
+
9
+ const args = parseArgs();
10
+
11
+ let input; // Directcall input (positional ONLY - NO pipe)
12
+ if (args._.length === 1 && typeof args._[0] === 'string' && args._[0].trim() !== '') {
13
+ input = args._[0].trim();
14
+ }
15
+
16
+ const help = args['help'] || false;
17
+ const connect = args['connect'] ? args['connect'] : undefined;
18
+ const serve = args['serve'] ? parseInt(args['serve']) : undefined;
19
+
20
+ /** @type {import('lib/API/x.ai/responses.js').XAIOptions} */
21
+ const options = { tools: [] };
22
+ options.tools.push({
23
+ type: 'web_search'
24
+ });
25
+
26
+ if (args['secret']) {
27
+ secret = args['secret'];
28
+ }
29
+ if (args['model'] || true) {
30
+ options.model = args['model'] || 'grok-4-fast-reasoning';
31
+ }
32
+ if (args['temperature']) {
33
+ options.temperature = parseFloat(args['temperature']);
34
+ }
35
+ if (args['tokens']) {
36
+ options.max_output_tokens = parseInt(args['tokens']);
37
+ }
38
+ if (args['top_p']) {
39
+ options.top_p = parseFloat(args['top_p']);
40
+ }
41
+ const reasoning = true;
42
+ if (reasoning) {
43
+ options.reasoning = {
44
+ effort: 'medium',
45
+ summary: 'auto'
46
+ }
47
+ }
48
+ const toolsetMode = 'auto';
49
+ const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
50
+
51
+ function printHelp() {
52
+ console.log(`'${name} --help' You are looking at it.
53
+
54
+ ## USAGE MODES:
55
+
56
+ ### 1. Direct Call (One-Shot, Positional ONLY):
57
+ ./examples/${name}.js "Optimize this prompt: [prompt]" [--options]
58
+
59
+ ### 2. Interactive CLI (no positional arg):
60
+ ./examples/${name}.js [--options]
61
+
62
+ ### 3. WS Server (no positional arg):
63
+ ./examples/${name}.js --serve 8080 [--secret mysecret] [--options]
64
+
65
+ ### 4. WS Client (no positional arg):
66
+ ./examples/${name}.js --connect ws://127.0.0.1:8080/ws --secret mysecret [--options]
67
+
68
+ ### 5. Hybrid (Server + Client, no positional arg):
69
+ ./examples/${name}.js --serve 8081 --connect ws://other:8080/ws [--secret ...] [--options]
70
+
71
+ ## SERVER OPTIONS EXPLAINED:
72
+ --serve [port]: Starts WebSocket SERVER at ws://127.0.0.1:[port]/ws. Allows other agents (--connect) to connect and use this agent as a remote TOOL (e.g., 'prompt_agent'). Runs indefinitely until Ctrl+C.
73
+
74
+ --connect [ws_url]: Connects as CLIENT to remote WS server at [ws_url] (e.g., ws://127.0.0.1:8080/ws). Gains access to remote agent's tools. Interactive CLI available.
75
+
76
+ --secret [string]: SHARED AUTH TOKEN (min 3 chars). SERVER rejects clients without matching --secret. CLIENTS must provide server's secret to connect. Use same secret for chains.
77
+
78
+ Note: Server/Client/Hybrid IGNORES positional input arg (use CLI modes instead). Hybrid: This agent serves AND uses remote tools.
79
+
80
+ ## OPTIONS:
81
+ --model [grok-4-fast-reasoning|...] (default: grok-4-fast-reasoning)
82
+ --temperature [float] (-2 to +2)
83
+ --tokens [number] (max output tokens)
84
+ --top_p [float]
85
+ --context [number] (default: 250000)
86
+
87
+ ## SERVER TOOLS (when no input):
88
+ Exposes as 'prompt_agent' tool for chaining.
89
+ `);
90
+ process.exit();
91
+ }
92
+
93
+ if (help) {
94
+ printHelp();
95
+ }
96
+
97
+ const tool_call_name = 'prompt_agent';
98
+ const tool_call_description = `Prompt optimizer. Analyzes prompts for clarity, brevity, ethics, token efficiency. Approves good ones or rewrites with summary/questions.`.trim();
99
+
100
+ const prompt = `**CRITICAL: STRICT NO-CODING RULE** - Stick to prompt optimization ONLY. NEVER:
101
+ - Use execute_bash_script, javascript_interpreter, write_file, read_file, syntax_check.
102
+ - Generate, execute, or edit code.
103
+ If asked to code, decline: "For code tasks, use code_agent.js. I optimize prompts only."
104
+
105
+ You are a prompt optimizer. Check for: 1) Clarity and specificity. 2) Brevity, non-ambiguity, ethics. 3) Token efficiency. If good, say "Approved." If not, rewrite concisely or ask 1-2 questions. Output: - Summary. - Rewritten prompt (if needed). - Questions (if unclear). Be efficient.
106
+
107
+ Current date: April 01, 2026.`.trim();
108
+
109
+ const agent = new AgentManager({ name, secret });
110
+ agent.setup({
111
+ prompt,
112
+ api,
113
+ options,
114
+ toolsetMode,
115
+ contextWindow
116
+ });
117
+ const toolset = agent.getToolset();
118
+ if (toolset) {
119
+ agent.addGenericToolcall('history_search');
120
+ agent.addGenericToolcall('open_link');
121
+ agent.addGenericToolcall('send_email');
122
+ // Removed execute_bash_script and javascript_interpreter for NO-CODING compliance
123
+ }
124
+ const cliIntro = `${name} ${options.model}.
125
+ - context: ${contextWindow}.
126
+ ${tool_call_name}`.trim();
127
+
128
+ if (input) {
129
+ const RES = await agent.directCall(input);
130
+ console.log(RES);
131
+ } else {
132
+ await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
133
+ }
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ import { AgentManager } from '@j-o-r/hello-dave';
3
+ import { parseArgs, readIn } from '@j-o-r/sh';
4
+
5
+ const name = 'readme_agent';
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
+ options.tools.push({
17
+ type: 'web_search'
18
+ });
19
+ if (args['secret']) { // model gets default value
20
+ secret = args['secret'];
21
+ }
22
+ // Set properties only if provided via command line (except model which has default)
23
+ if (args['model'] || true) { // model gets default value
24
+ // @ts-ignore
25
+ options.model = args['model'] || 'grok-4-fast-reasoning';
26
+ }
27
+ if (args['temperature']) {
28
+ options.temperature = parseFloat(args['temperature']);
29
+ }
30
+ if (args['tokens']) {
31
+ options.max_output_tokens = parseInt(args['tokens']);
32
+ }
33
+ if (args['top_p']) {
34
+ options.top_p = parseFloat(args['top_p']);
35
+ }
36
+ const reasoning = args['reasoning'] ? args['reasoning'] : null;
37
+ if (reasoning) {
38
+ options.reasoning = {
39
+ // @ts-ignore
40
+ effort: reasoning,
41
+ summary: 'auto'
42
+ }
43
+ }
44
+
45
+ const toolsetMode = 'auto';
46
+ const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
47
+
48
+ // Copy from the generic toolset
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 [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
58
+ --top_p [float]: number > 0, 0.1 means no top_p
59
+ --reasoning [low|high]
60
+ --tools [javascript,bash] 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
+ process.exit()
68
+ }
69
+
70
+ if (help) {
71
+ printHelp();
72
+ }
73
+
74
+ const tool_call_description = `
75
+ Project README manager. Maintains README.md with comprehensive project documentation.
76
+ Inspects current README.md, updates sections (installation, usage, etc.), generates content based on project files and user input.
77
+ Suggests improvements, adds badges, TOC, etc.
78
+ `.trim();
79
+ const tool_call_name = 'readme_agent';
80
+ const prompt = `
81
+ You are an expert README.md manager for this project. README.md should follow best practices with sections like:
82
+
83
+ # Project Title
84
+ ![Badges]
85
+
86
+ ## Table of Contents
87
+
88
+ ## Description
89
+ ## Features
90
+ ## Installation
91
+ ## Usage
92
+ ## Examples
93
+ ## Development
94
+ ## Contributing
95
+ ## License
96
+
97
+ **CRITICAL: STRICT NO-CODING RULE** - Stick to README management ONLY. NEVER:
98
+ - Use coding tools (e.g., javascript_interpreter, read_file, write_file, syntax_check, npm_module_inspector).
99
+ - Generate, execute, or edit code (JS/Python/Bash beyond safe README ops).
100
+ - Misuse bash for anything beyond safe README.md ops (e.g., cat README.md, echo > README.md, cp README.md README.md.bak, ls, git status).
101
+ If asked to code or edit non-README files, decline: "For coding or other tasks, use specialized agents like code_agent. I'll handle README.md only."
102
+
103
+ ALWAYS:
104
+
105
+ 1. Inspect the current README.md if it exists (use \`cat README.md\` or similar).
106
+
107
+ 2. Inspect key project files safely: \`cat package.json\`, \`ls -la\`, \`ls bin/\`, \`ls lib/\`, \`git status\`, etc.
108
+
109
+ 3. Understand the user input:
110
+ - "add installation instructions"
111
+ - "generate usage examples"
112
+ - "add table of contents"
113
+ - "update description to: ..."
114
+ - "suggest improvements"
115
+ - "include npm badges"
116
+ - "make it more professional"
117
+
118
+ 4. Update README.md with changes. Ensure excellent Markdown formatting, accuracy based on project. Backup first if overwriting: \`cp README.md README.md.bak\`.
119
+
120
+ 5. Write the FULL updated content to ./README.md using safe bash (e.g., echo "content" > README.md).
121
+
122
+ 6. In your response, summarize:
123
+ - Changes made
124
+ - Preview of key sections (e.g., first 20 lines)
125
+ - Any suggestions for further enhancements
126
+
127
+ If no README.md exists, create a comprehensive one by analyzing the entire project: package.json, code structure, scripts, etc. Infer project name, description, usage from files.
128
+
129
+ Use execute_bash_script ONLY for safe README ops and inspections. Use web_search for best practices if needed.
130
+ `.trim();
131
+ const agent = new AgentManager({ name, secret });
132
+ agent.setup({
133
+ prompt,
134
+ api,
135
+ options,
136
+ toolsetMode,
137
+ contextWindow
138
+ });
139
+ const toolset = agent.getToolset();
140
+ if (toolset) {
141
+ agent.addGenericToolcall('execute_bash_script');
142
+ }
143
+ const cliIntro = `
144
+ ${name} ${options.model}.
145
+ - context: ${contextWindow}
146
+ `.trim();
147
+
148
+ await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);