@j-o-r/hello-dave 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -26
- package/README.md +161 -522
- package/README.md.bak +144 -449
- package/{examples → agents}/ask_agent.js +5 -5
- package/{examples → agents}/codeserver.sh +14 -14
- package/{examples → agents}/daisy_agent.js +5 -5
- package/{examples → agents}/docs_agent.js +5 -5
- package/{examples → agents}/gpt_agent.js +5 -5
- package/{examples → agents}/grok_agent.js +5 -5
- package/agents/memory_agent.js +263 -0
- package/{examples → agents}/npm_agent.js +5 -5
- package/{examples → agents}/prompt_agent.js +5 -5
- package/agents/spawn_agent.js +137 -0
- package/{examples → agents}/test_agent.js +6 -8
- package/{examples → agents}/todo_agent.js +5 -5
- package/bin/codeDave +58 -0
- package/bin/dave.js +114 -96
- package/lib/AgentClient.js +111 -67
- package/lib/AgentManager.js +111 -80
- package/lib/AgentServer.js +144 -104
- package/lib/Cli.js +126 -93
- package/lib/Prompt.js +38 -5
- package/lib/Session.js +102 -79
- package/lib/ToolSet.js +79 -60
- package/lib/fafs.js +54 -19
- package/lib/genericToolset.js +109 -213
- package/lib/wsCli.js +50 -19
- package/lib/wsIO.js +11 -17
- package/package.json +2 -2
- package/types/AgentClient.d.ts +69 -35
- package/types/AgentManager.d.ts +50 -56
- package/types/AgentServer.d.ts +63 -16
- package/types/Cli.d.ts +56 -10
- package/types/Prompt.d.ts +36 -4
- package/types/Session.d.ts +23 -9
- package/types/ToolSet.d.ts +49 -32
- package/types/fafs.d.ts +68 -25
- package/types/wsCli.d.ts +14 -0
- package/types/wsIO.d.ts +9 -5
- package/utils/search_sessions.sh +100 -53
- package/README.md.backup +0 -269
- package/README.md.bak.1774780058 +0 -338
- package/README.md.bak2 +0 -531
- package/bin/spawn_agent.js +0 -293
- package/docs.bak.1774780058/agent-manager.md +0 -167
- package/docs.bak.1774780058/agent-manager.md.bak +0 -137
- package/docs.bak.1774780058/agent-manager.md.bak2 +0 -157
- package/docs.bak.1774780058/codeserver-pattern.md +0 -191
- package/docs.bak.1774780058/path-resolution-best-practices.md +0 -104
- package/docs.bak.1774780058/project-overview.md +0 -67
- package/docs.bak.1774780058/project-overview.md.bak +0 -67
- package/docs.bak.1774780058/prompt-class.md +0 -141
- package/docs.bak.1774780058/prompt-class.md.bak +0 -142
- package/docs.bak.1774780058/tools-syntax-validation.md +0 -121
- package/docs.bak.1774780058/tools-syntax-validation.md.bak2 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak3 +0 -125
- package/docs.bak.1774780058/tools-syntax-validation.md.bak4 +0 -106
- package/docs.bak.1774780058/tools-syntax-validation.md.bak_path +0 -106
- package/docs.bak.1774780058/toolset.md +0 -164
- package/docs.bak.1774780058/toolset.md.bak +0 -94
- package/docs.bak.1774780058/toolset.md.bak3 +0 -161
- package/docs.bak.1774780058/toolset.md.bak4 +0 -161
- package/docs.bak.1774780058/toolset.md.bak5 +0 -161
- package/docs.bak.1774780058/toolset.md.bak6 +0 -163
- package/docs.bak.1774780058/toolset.md.bak_path +0 -163
- package/docs.bak.1774780058/toolset.md.bak_syntax +0 -161
- package/docs.bak.1774780058/xai-responses.md +0 -111
- package/docs.bak.1774780058/xai-responses.md.bak +0 -107
- package/docs.bak.1774780058/xai-responses.md.bak2 +0 -107
- package/docs.bak.1774780058/xai_collections.md +0 -106
- package/examples/memory_agent.js +0 -152
- package/examples.bak.1774780058/ask_agent.js +0 -114
- package/examples.bak.1774780058/code_agent.js +0 -149
- package/examples.bak.1774780058/coderev_agent.js +0 -72
- package/examples.bak.1774780058/codeserver.sh +0 -47
- package/examples.bak.1774780058/daisy_agent.js +0 -177
- package/examples.bak.1774780058/docs_agent.js +0 -119
- package/examples.bak.1774780058/gpt_agent.js +0 -109
- package/examples.bak.1774780058/grok_agent.js +0 -98
- package/examples.bak.1774780058/memory_agent.js +0 -112
- package/examples.bak.1774780058/npm_agent.js +0 -175
- package/examples.bak.1774780058/prompt_agent.js +0 -112
- package/examples.bak.1774780058/readme_agent.js +0 -144
- package/examples.bak.1774780058/spawn_agent.js +0 -263
- package/examples.bak.1774780058/test_agent.js +0 -162
- package/examples.bak.1774780058/todo_agent.js +0 -138
- package/lib/genericToolset.js.bak_syntax +0 -402
- package/scenarios.bak.1774780058/data/eval_node_message.json +0 -9
- package/scenarios.bak.1774780058/data/hist_oa.json +0 -66
- package/scenarios.bak.1774780058/data/o3_response1.json +0 -96
- package/scenarios.bak.1774780058/data/oa_reasoning_parse.json +0 -112
- package/scenarios.bak.1774780058/data/tool_oa.json +0 -96
- package/scenarios.bak.1774780058/data/tool_xai.json +0 -59
- package/scenarios.bak.1774780058/data/tool_xai2.json +0 -40
- package/scenarios.bak.1774780058/data/xai-response-1.json +0 -59
- package/scenarios.bak.1774780058/data/xai-response-2.json +0 -10
- package/scenarios.bak.1774780058/data/xai_reasoning_tools_resp.json +0 -59
- package/scenarios.bak.1774780058/data/xai_search_response.json +0 -58
- package/scenarios.bak.1774780058/environment.js +0 -10
- package/scenarios.bak.1774780058/example.js +0 -17
- package/scenarios.bak.1774780058/genericToolset.test.js +0 -182
- package/scenarios.bak.1774780058/grok.js +0 -113
- package/scenarios.bak.1774780058/memory-tools.js +0 -51
- package/scenarios.bak.1774780058/openai-o3.js +0 -137
- package/scenarios.bak.1774780058/openai-prompt.js +0 -155
- package/scenarios.bak.1774780058/openai-session.js +0 -148
- package/scenarios.bak.1774780058/openai.js +0 -102
- package/scenarios.bak.1774780058/prompt.js +0 -118
- package/scenarios.bak.1774780058/promptFishbowl.js +0 -76
- package/scenarios.bak.1774780058/search.brave.com.js +0 -25
- package/scenarios.bak.1774780058/sh.js +0 -15
- package/scenarios.bak.1774780058/test-wsio.js +0 -26
- package/scenarios.bak.1774780058/testToolset.js +0 -42
- package/scenarios.bak.1774780058/toolset.js +0 -16
- package/scenarios.bak.1774780058/toolset.test.js +0 -141
- package/scenarios.bak.1774780058/write_file_syntax.test.js +0 -145
- package/scenarios.bak.1774780058/write_file_validation/README.md +0 -30
- package/scenarios.bak.1774780058/write_file_validation/bad.js +0 -3
- package/scenarios.bak.1774780058/write_file_validation/good.js +0 -4
- package/scenarios.bak.1774780058/write_file_validation/test.sh +0 -43
- package/scenarios.bak.1774780058/wsClient.js +0 -69
- package/scenarios.bak.1774780058/xai_responses.integration.test.js +0 -57
- package/scenarios.bak.1774780058/xai_responses.test.js +0 -154
- package/scenarios.bak.1774780058/xaicoll.js +0 -50
- package/scenarios.bak.1774780058/xaifiles.js +0 -48
- /package/{examples → agents}/code_agent.js +0 -0
- /package/{examples → agents}/readme_agent.js +0 -0
|
@@ -1,175 +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_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 = { tools : []};
|
|
17
|
-
options.tools.push({
|
|
18
|
-
type: 'web_search'
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (args['secret']) { // model gets default value
|
|
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-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
|
-
const reasoning = true; // args['reasoning'] ? args['reasoning'] : null;
|
|
39
|
-
if (reasoning) {
|
|
40
|
-
options.reasoning = {
|
|
41
|
-
effort: 'medium',
|
|
42
|
-
summary: 'auto'
|
|
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
|
|
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
|
-
`);
|
|
68
|
-
process.exit()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (help) {
|
|
72
|
-
printHelp();
|
|
73
|
-
}
|
|
74
|
-
const tool_call_name = 'npm_module_inspector';
|
|
75
|
-
const tool_call_description = `
|
|
76
|
-
NPM modules expert (scoped & unscoped). Uses \`npm ls\` + bash **exclusively inside ./node_modules/**.
|
|
77
|
-
**Smart Cache**: .cache/npm-agent-storage.md (auto-read/update, token-efficient, auto-refreshes on changes). Agent-owned.
|
|
78
|
-
`.trim();
|
|
79
|
-
|
|
80
|
-
const CACHE_FILE='.cache/npm-agent-storage.md';
|
|
81
|
-
|
|
82
|
-
const prompt = `
|
|
83
|
-
You are a coding assistant specializing in Bash and JavaScript (ESM/ESNext), with support for other languages.
|
|
84
|
-
Your role: Help users code with external NPM modules installed in the project's ./node_modules/ (dynamic CWD).
|
|
85
|
-
Scoped (@j-o-r/cli) == unscoped (gpt-3-encoder) priority.
|
|
86
|
-
|
|
87
|
-
CWD dynamic (pwd; project root w/ package.json/node_modules).
|
|
88
|
-
|
|
89
|
-
CRITICAL: **NEVER** inspect/read **OUTSIDE** ./node_modules/. NO project files. **ONLY** \`npm ls\` (local) + node_modules/ paths.
|
|
90
|
-
|
|
91
|
-
**Smart Cache (${CACHE_FILE})**: Agent-owned, hidden, **auto-managed** (read-first, update-on-change, NO user confirm).
|
|
92
|
-
- **Token Saver**: Grep cache **FIRST** (if match version → use, skip inspect).
|
|
93
|
-
- **Auto-Update**: ALWAYS check \`npm ls \$PKG_NAME\`; if version changed/missing → inspect + **silently rewrite** section.
|
|
94
|
-
- Init: \`touch ${CACHE_FILE}\`
|
|
95
|
-
|
|
96
|
-
PRIORITIZE \`npm ls --depth=1\` (versions/tree) + bash **inside** MODULE_DIR.
|
|
97
|
-
|
|
98
|
-
Tools:
|
|
99
|
-
- execute_bash_script: \`npm ls ...\` + \`cat node_modules/\$PKG_NAME/package.json\`. **node_modules/ prefix ALWAYS**.
|
|
100
|
-
- web_search: Docs supplement.
|
|
101
|
-
- history_search: Chats.
|
|
102
|
-
|
|
103
|
-
**Smart Workflow** (per query; e.g., "@j-o-r/cli"):
|
|
104
|
-
1. **Confirm Installed/Version**:
|
|
105
|
-
\`CURRENT_VERSION=\$(npm ls "\$PKG_NAME" --depth=0 2>/dev/null | grep -o ' @[0-9].*' | sed 's/ @//') || echo "Not installed"\`
|
|
106
|
-
|
|
107
|
-
2. **Smart Cache Check** (token-efficient):
|
|
108
|
-
- Init: \`touch ${CACHE_FILE}\`
|
|
109
|
-
- Exact match? \`grep -A 30 "^## \$PKG_NAME v\$CURRENT_VERSION " ${CACHE_FILE} || echo "Cache miss/outdated"\`
|
|
110
|
-
- If hit: Use cache summary (paste relevant sections). **Skip** full inspect.
|
|
111
|
-
- List all: \`grep "^## " ${CACHE_FILE} | sed 's/^## //' || echo "Empty cache"\`
|
|
112
|
-
|
|
113
|
-
3. **Inspect if Cache Miss/Outdated** (set MODULE_DIR=node_modules/\$PKG_NAME):
|
|
114
|
-
- Path: \`[ -d "node_modules/\$PKG_NAME" ] && echo "OK" || echo "Dir missing"\`
|
|
115
|
-
- Desc: \`grep '"description"' "node_modules/\$PKG_NAME/package.json" | sed 's/.*"description": "\\([^"]*\\)".*/\\1/' || echo "No desc"\`
|
|
116
|
-
- Entrypoints: \`grep -E '"(main|module|types|exports)"' "node_modules/\$PKG_NAME/package.json" || echo "None"\`
|
|
117
|
-
- README: \`head -50 "node_modules/\$PKG_NAME/README.md" 2>/dev/null || echo "No README"\`
|
|
118
|
-
- Types/Exports: \`find "node_modules/\$PKG_NAME" -name "*.d.ts" 2>/dev/null | head -8 | xargs grep -hE "export (interface|type|function|class|const)" | head -25 || find "node_modules/\$PKG_NAME" -name "*.{ts,js,mjs,cjs}" 2>/dev/null | head -8 | xargs grep -hE "export " | head -25 || echo "No exports"\`
|
|
119
|
-
- Examples: \`grep -rniE "example|usage|demo" "node_modules/\$PKG_NAME/" 2>/dev/null | head -15 || echo "No examples"\`
|
|
120
|
-
- Subdeps: \`npm ls "\$PKG_NAME" --depth=1\`
|
|
121
|
-
|
|
122
|
-
4. **Auto-Update Cache** (**ALWAYS after inspect**, silent, replace section):
|
|
123
|
-
\`sed -i.bak "/^## \$PKG_NAME /,/^## \\|^$/d" ${CACHE_FILE} && rm ${CACHE_FILE}.bak 2>/dev/null; cat >> ${CACHE_FILE} << 'EOC'
|
|
124
|
-
## \$PKG_NAME v\$CURRENT_VERSION
|
|
125
|
-
|
|
126
|
-
### Overview
|
|
127
|
-
\$DESC
|
|
128
|
-
|
|
129
|
-
### Installation
|
|
130
|
-
Installed (\$CURRENT_VERSION). import {example} from '\$PKG_NAME'; // ESM
|
|
131
|
-
|
|
132
|
-
### Usage Examples
|
|
133
|
-
\$EXAMPLES
|
|
134
|
-
|
|
135
|
-
### API Reference
|
|
136
|
-
\$EXPORTS
|
|
137
|
-
|
|
138
|
-
### Dependencies
|
|
139
|
-
\$SUBDEPS
|
|
140
|
-
|
|
141
|
-
### Notes
|
|
142
|
-
Best practices/gotchas from README/types.
|
|
143
|
-
EOC\`
|
|
144
|
-
|
|
145
|
-
5. **List All Modules** (top-level, cached/versions):
|
|
146
|
-
\`npm ls --depth=0 | grep -E '^[├└]──' | sed 's/^[├└ ]*── //' | sed 's/ .*//' || echo "npm ls --depth=0"\`
|
|
147
|
-
|
|
148
|
-
6. **Coding Help**: ESM snippets, errors (\`npm ls --why=\$PKG_NAME\`), best practices (cache + local + web).
|
|
149
|
-
|
|
150
|
-
**MANDATORY**: Cache-first. Auto-update **every time** version changes/miss. **No asks**. Scoped=unscoped. Portable.
|
|
151
|
-
`.trim();
|
|
152
|
-
|
|
153
|
-
const agent = new AgentManager({ name, secret });
|
|
154
|
-
agent.setup({
|
|
155
|
-
prompt,
|
|
156
|
-
api,
|
|
157
|
-
options,
|
|
158
|
-
toolsetMode,
|
|
159
|
-
contextWindow
|
|
160
|
-
});
|
|
161
|
-
const toolset = agent.getToolset();
|
|
162
|
-
if (toolset) {
|
|
163
|
-
agent.addGenericToolcall('history_search');
|
|
164
|
-
agent.addGenericToolcall('javascript_interpreter');
|
|
165
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
166
|
-
agent.addGenericToolcall('read_file');
|
|
167
|
-
agent.addGenericToolcall('write_file');
|
|
168
|
-
}
|
|
169
|
-
const cliIntro = `
|
|
170
|
-
${name} ${options.model}.
|
|
171
|
-
- context: ${contextWindow}. Smart cache: ${CACHE_FILE} (auto).
|
|
172
|
-
${tool_call_name}
|
|
173
|
-
`.trim();
|
|
174
|
-
|
|
175
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|
|
@@ -1,112 +0,0 @@
|
|
|
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 = 'prompt_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
|
-
|
|
23
|
-
if (args['secret']) { // model gets default value
|
|
24
|
-
secret = args['secret'];
|
|
25
|
-
}
|
|
26
|
-
// Set properties only if provided via command line (except model which has default)
|
|
27
|
-
if (args['model'] || true) { // model gets default value
|
|
28
|
-
// @ts-ignore || grok-4-1-fast-non-reasoning
|
|
29
|
-
options.model = args['model'] || 'grok-4-1-fast-reasoning';
|
|
30
|
-
}
|
|
31
|
-
if (args['temperature']) {
|
|
32
|
-
options.temperature = parseFloat(args['temperature']);
|
|
33
|
-
}
|
|
34
|
-
if (args['tokens']) {
|
|
35
|
-
options.max_output_tokens = parseInt(args['tokens']);
|
|
36
|
-
}
|
|
37
|
-
if (args['top_p']) {
|
|
38
|
-
options.top_p = parseFloat(args['top_p']);
|
|
39
|
-
}
|
|
40
|
-
const reasoning = true // args['reasoning'] ? args['reasoning'] : null;
|
|
41
|
-
if (reasoning) {
|
|
42
|
-
// options.reasoning_effort = reasoning
|
|
43
|
-
options.reasoning = {
|
|
44
|
-
effort: 'medium',
|
|
45
|
-
summary: 'auto'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Large context on grok-4-fast
|
|
49
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 1900000;
|
|
50
|
-
const toolsetMode = 'auto';
|
|
51
|
-
|
|
52
|
-
function printHelp() {
|
|
53
|
-
console.log(`
|
|
54
|
-
'${name} --help' You are looking at it.
|
|
55
|
-
'
|
|
56
|
-
OPTIONS:
|
|
57
|
-
--tokens [number]: max generated tokens
|
|
58
|
-
--context [number] : truncate message history to context-windows size default 130000
|
|
59
|
-
--temperature [float] : -2 / +2
|
|
60
|
-
--model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
|
|
61
|
-
--top_p [float]: number > 0, 0.1 means no top_p
|
|
62
|
-
--reasoning [low|high]
|
|
63
|
-
--tools [javascript,bash] comma seperated list
|
|
64
|
-
|
|
65
|
-
SERVER TOOLS:
|
|
66
|
-
--serve [number]: create a Agent server on port number ws://127.0.0.1:[serve]/ws
|
|
67
|
-
--connect [url]: connect to a Server Agent e.g ws://127.0.0.1:8080/ws (https://my.domain/ws) ...
|
|
68
|
-
--secret [string] : limit access to websocket server with a secret
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`);
|
|
72
|
-
process.exit()
|
|
73
|
-
}
|
|
74
|
-
if (help) {
|
|
75
|
-
printHelp();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const prompt = `
|
|
79
|
-
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.
|
|
80
|
-
`.trim();
|
|
81
|
-
|
|
82
|
-
const agent = new AgentManager({ name, secret });
|
|
83
|
-
agent.setup({
|
|
84
|
-
prompt,
|
|
85
|
-
api,
|
|
86
|
-
options,
|
|
87
|
-
toolsetMode,
|
|
88
|
-
contextWindow
|
|
89
|
-
});
|
|
90
|
-
agent.addGenericToolcall('open_link');
|
|
91
|
-
agent.addGenericToolcall('send_email');
|
|
92
|
-
agent.addGenericToolcall('history_search');
|
|
93
|
-
|
|
94
|
-
const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
|
|
95
|
-
if (addTools.includes('javascript')) {
|
|
96
|
-
agent.addGenericToolcall('javascript_interpreter');
|
|
97
|
-
}
|
|
98
|
-
if (addTools.includes('bash')) {
|
|
99
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
100
|
-
}
|
|
101
|
-
if (addTools.includes('ssh')) {
|
|
102
|
-
agent.addGenericToolcall('execute_remote_script');
|
|
103
|
-
}
|
|
104
|
-
const cliIntro = `
|
|
105
|
-
${name} ${options.model}.
|
|
106
|
-
- context: ${contextWindow}
|
|
107
|
-
`.trim();
|
|
108
|
-
|
|
109
|
-
const description = `
|
|
110
|
-
Given a specific prompt, inspect and adjust it for better readability and clarity.
|
|
111
|
-
`.trim();
|
|
112
|
-
await agent.start(serve, connect, cliIntro, "prompt_engineer_agent", description);
|
|
@@ -1,144 +0,0 @@
|
|
|
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_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 = { 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
|
-
if (reasoning) {
|
|
39
|
-
options.reasoning = {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
effort: reasoning,
|
|
42
|
-
summary: 'auto'
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const toolsetMode = 'auto';
|
|
48
|
-
const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
|
|
49
|
-
|
|
50
|
-
// Copy from the generic toolset
|
|
51
|
-
function printHelp() {
|
|
52
|
-
console.log(`
|
|
53
|
-
'${name} --help' You are looking at it.
|
|
54
|
-
|
|
55
|
-
OPTIONS:
|
|
56
|
-
--tokens [number]: max generated tokens
|
|
57
|
-
--context [number] : truncate message history to context-windows size default 130000
|
|
58
|
-
--temperature [float] : -2 / +2
|
|
59
|
-
--model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
|
|
60
|
-
--top_p [float]: number > 0, 0.1 means no top_p
|
|
61
|
-
--reasoning [low|high]
|
|
62
|
-
--tools [javascript,bash] comma seperated list
|
|
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
|
-
process.exit()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (help) {
|
|
73
|
-
printHelp();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const tool_call_description = `
|
|
77
|
-
Project README manager. Maintains README.md with comprehensive project documentation.
|
|
78
|
-
Inspects current README.md, updates sections (installation, usage, etc.), generates content based on project files and user input.
|
|
79
|
-
Suggests improvements, adds badges, TOC, etc.
|
|
80
|
-
`.trim();
|
|
81
|
-
const tool_call_name = 'readme_agent';
|
|
82
|
-
const prompt = `
|
|
83
|
-
You are an expert README.md manager for this project. README.md should follow best practices with sections like:
|
|
84
|
-
|
|
85
|
-
# Project Title
|
|
86
|
-
![Badges]
|
|
87
|
-
|
|
88
|
-
## Table of Contents
|
|
89
|
-
|
|
90
|
-
## Description
|
|
91
|
-
## Features
|
|
92
|
-
## Installation
|
|
93
|
-
## Usage
|
|
94
|
-
## Examples
|
|
95
|
-
## Development
|
|
96
|
-
## Contributing
|
|
97
|
-
## License
|
|
98
|
-
|
|
99
|
-
ALWAYS:
|
|
100
|
-
|
|
101
|
-
1. Inspect the current README.md if it exists (\`cat README.md\` or similar).
|
|
102
|
-
|
|
103
|
-
2. Inspect key project files: \`cat package.json\`, \`ls -la\`, \`ls bin/\`, \`ls lib/\`, \`git status\`, etc.
|
|
104
|
-
|
|
105
|
-
3. Understand the user input:
|
|
106
|
-
- "add installation instructions"
|
|
107
|
-
- "generate usage examples"
|
|
108
|
-
- "add table of contents"
|
|
109
|
-
- "update description to: ..."
|
|
110
|
-
- "suggest improvements"
|
|
111
|
-
- "include npm badges"
|
|
112
|
-
- "make it more professional"
|
|
113
|
-
|
|
114
|
-
4. Update README.md with changes. Ensure excellent Markdown formatting, accuracy based on project.
|
|
115
|
-
|
|
116
|
-
5. Write the FULL updated content to ./README.md.
|
|
117
|
-
|
|
118
|
-
6. In your response, summarize:
|
|
119
|
-
- Changes made
|
|
120
|
-
- Preview of key sections (e.g., first 20 lines)
|
|
121
|
-
- Any suggestions for further enhancements
|
|
122
|
-
|
|
123
|
-
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.
|
|
124
|
-
|
|
125
|
-
Use tools to read files, list directories, etc., as needed.
|
|
126
|
-
`.trim();
|
|
127
|
-
const agent = new AgentManager({ name, secret });
|
|
128
|
-
agent.setup({
|
|
129
|
-
prompt,
|
|
130
|
-
api,
|
|
131
|
-
options,
|
|
132
|
-
toolsetMode,
|
|
133
|
-
contextWindow
|
|
134
|
-
});
|
|
135
|
-
const toolset = agent.getToolset();
|
|
136
|
-
if (toolset) {
|
|
137
|
-
agent.addGenericToolcall('execute_bash_script');
|
|
138
|
-
}
|
|
139
|
-
const cliIntro = `
|
|
140
|
-
${name} ${options.model}.
|
|
141
|
-
- context: ${contextWindow}
|
|
142
|
-
`.trim();
|
|
143
|
-
|
|
144
|
-
await agent.start(serve, connect, cliIntro, tool_call_name, tool_call_description);
|