@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
package/bin/hdPrompt.js DELETED
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
- import AgentManager from '../lib/AgentManager.js';
3
- import { parseArgs, readIn } from '@j-o-r/sh';
4
-
5
- // const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
6
- const name = 'hdPrompt';
7
- const api = 'grok';
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/text.js').XOptions} */
16
- const options = {}
17
- // Set properties only if provided via command line (except model which has default)
18
- if (args['model'] || true) { // model gets default value
19
- // @ts-ignore
20
- options.model = args['model'] || 'grok-4';
21
- }
22
- if (args['temperature']) {
23
- options.temperature = parseFloat(args['temperature']);
24
- }
25
- if (args['tokens']) {
26
- options.max_completion_tokens = parseInt(args['tokens']);
27
- }
28
- if (args['top_p']) {
29
- options.top_p = parseFloat(args['top_p']);
30
- }
31
-
32
- options.search_parameters = { mode: 'auto' }
33
- // @ts-ignore
34
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
35
- if (reasoning) {
36
- // @ts-ignore
37
- options.reasoning_effort = reasoning
38
- }
39
- const toolsetMode = (args.tools) ? 'auto' : undefined;
40
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
41
-
42
- function printHelp() {
43
- console.log(`
44
- '${name} --help' You are looking at it.
45
- '
46
- OPTIONS:
47
- --tokens [number]: max generated tokens
48
- --context [number] : truncate message history to context-windows size default 130000
49
- --temperature [float] : -2 / +2
50
- --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast]
51
- --top_p [float]: number > 0, 0.1 means no top_p
52
- --reasoning [low|high]
53
- --tools [javascript,bash] comma seperated list
54
- e.g.
55
- grok.js --model grok-3-mini --tokens 4000 --context 10000
56
-
57
- `);
58
- process.exit()
59
- }
60
-
61
- if (help) {
62
- printHelp();
63
- }
64
- // reason step by step
65
-
66
- const prompt = `
67
- 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.
68
- `.trim();
69
- const agent = new AgentManager({ name });
70
- agent.setup({
71
- prompt,
72
- api,
73
- options,
74
- toolsetMode,
75
- contextWindow
76
- });
77
- const toolset = agent.getToolset();
78
- if (toolset) {
79
- const addTools = args['tools'].split(',') || [];
80
- if (addTools.includes('javascript')) {
81
- agent.addGenericToolcall('javascript_interpreter')
82
- }
83
- if (addTools.includes('bash')) {
84
- agent.addGenericToolcall('execute_bash_script');
85
- }
86
- }
87
-
88
- const cliIntro = `
89
- ${name} ${options.model}.
90
- search ${options.search_parameters.mode}
91
- `.trim();
92
-
93
- const description = `
94
- Given a specific prompt, inspect and adjust it for better readability and clarity.
95
- `.trim();
96
-
97
- if (input === '' && serve) {
98
- agent.enableServer(name, description, serve);
99
- }
100
- if (input !== '') {
101
- // Direct input output
102
- const res = await agent.directCall(input);
103
- console.log(res);
104
- } else if(connect) {
105
- agent.attach(name, description, connect)
106
- } else {
107
- agent.startCli(cliIntro);
108
- }
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * Claude test with a simple toolset
4
- */
5
- // -------------------------------
6
- const PROMPT_NAME = 'claude-test'
7
- // ------------------------------
8
- import { Prompt, API, CliWrapper, Session, env } from '../lib/index.js';
9
- import { parseArgs, SH } from '@j-o-r/sh';
10
- import toolset from '../lib/testToolset.js';
11
-
12
- const session = new Session(PROMPT_NAME);
13
-
14
- const args = parseArgs();
15
- // Get parameter values
16
- const max_completion_tokens = args['tokens'] ? parseInt(args['tokens']) : 4000;
17
- const context_window = args['context'] ? parseInt(args['context']) : 7000;
18
- const temperature = args['temperature'] ? parseFloat(args['temperature']) : 0.4;
19
- const model = args['model'] ? args['model'] : 'claude-3-7-sonnet-latest';
20
- const thinking = args['thinking'] ? parseInt(args['thinking']) : 0;
21
- const search = args['search'] ? parseInt(args['search']) : 0;
22
- const help = args['help'] || false;
23
-
24
- function printHelp() {
25
- console.log(`
26
- '${PROMPT_NAME} --help' You are looking at it.
27
- '
28
- OPTIONS:
29
- --tokens [number]: max generated tokens default 4000
30
- --context [number] : truncate message history to context-windows size default 700
31
- --temperature [float] : -2 / +2 default 0.4
32
- --model [grok-3|grok-3-mini|grok-3-mini-fast]
33
- --thinking [number_of_tokens] default 0
34
- --search [number_of_search_request] default 0 (no search)
35
- e.g.
36
- daisy --model grok-3-mini --tokens 4000 --context 10000
37
-
38
- `);
39
- process.exit()
40
- }
41
-
42
- const userInfo = await env();
43
- /** @type {import('lib/API/anthropic.com/text.js').SearchOptions} */
44
- const searchOptions = {
45
- type: 'web_search_20250305',
46
- name: 'web_search',
47
- max_uses: 5,
48
- user_location: {
49
- type: 'approximate',
50
- timezone: userInfo.timezone,
51
- region: userInfo.region,
52
- city: userInfo.city,
53
- country: userInfo.country
54
- }
55
- }
56
- if (help) {
57
- printHelp();
58
- }
59
- // reason step by step
60
-
61
- const PROMPT = `
62
- You an assistant dedicated to answering questions.
63
- - Reason step by step.
64
- - Be very brief.
65
- `.trim();
66
- const prompt = new Prompt(context_window);
67
- prompt.add('system', PROMPT.trim(), true);
68
- /** @type {import('lib/API/anthropic.com/text.js').ANTHOptions} */
69
- const options = {
70
- model,
71
- temperature: temperature,
72
- max_tokens: max_completion_tokens
73
- }
74
- // Enable reasoning
75
- if (thinking > 0) {
76
- options.thinking = {
77
- type: "enabled",
78
- budget_tokens: thinking
79
- }
80
- }
81
- if (search > 0) {
82
- searchOptions.max_uses = search;
83
- options.search = searchOptions
84
- }
85
- const intro = `
86
- Hi, I am ${PROMPT_NAME} ${options.model}, your assistant in this project.
87
- `;
88
- const cli = new CliWrapper({ request: API.text[PROMPT_NAME], session, intro, prompt, toolset, options });
89
- cli.start();
@@ -1,143 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { parseArgs, readIn } from '@j-o-r/sh';
6
- import genTools from '../lib/genericToolset.js';
7
- import { env } from '../lib/index.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'claude';
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /** @type {import('lib/API/anthropic.com/text.js').ANTHOptions} */
19
- const options = {}
20
- // Set properties only if provided via command line (except model which has default)
21
- if (args['model'] || true) { // model gets default value
22
- // @ts-ignore
23
- options.model = args['model'] || 'claude-sonnet-4-0';
24
- }
25
- if (args['temperature']) {
26
- options.temperature = parseFloat(args['temperature']);
27
- }
28
- if (args['tokens']) {
29
- options.max_tokens = parseInt(args['tokens']);
30
- }
31
- if (args['top_p']) {
32
- options.top_p = parseFloat(args['top_p']);
33
- }
34
- if (args['top_k']) {
35
- options.top_k = parseInt(args['top_k']);
36
- }
37
-
38
- const thinking = args['thinking'] ? parseInt(args['thinking']) : 0;
39
- if (thinking > 0) {
40
- options.thinking = {
41
- type: "enabled",
42
- budget_tokens: thinking
43
- }
44
- }
45
- const search = args['search'] ? parseInt(args['search']) : 7;
46
- if (search > 0) {
47
- const userInfo = await env();
48
- options.search = {
49
- type: 'web_search_20250305',
50
- name: 'web_search',
51
- max_uses: search,
52
- user_location: {
53
- type: 'approximate',
54
- timezone: userInfo.timezone,
55
- region: userInfo.region,
56
- city: userInfo.city,
57
- country: userInfo.country
58
- }
59
- }
60
- }
61
- const toolsetMode = (args.tools || serve) ? 'auto' : undefined;
62
- const contextWindow = args['context'] ? parseInt(args['context']) : 190000;
63
-
64
- function printHelp() {
65
- console.log(`
66
- '${name} --help' You are looking at it.
67
- '
68
- OPTIONS:
69
- --tokens [number]: max generated tokens
70
- --context [number] : truncate message history to context-windows size default 190000
71
- --temperature [float] : -2 / +2
72
- --model [claude-sonnet-4-0|other models]
73
- --top_p [float]: number > 0, 0.1 means no top_p
74
- --top_k [number]: number > 0 and < 2048
75
- --thinking [number]: thinking tokens (default: 0)
76
- --search [number]: number of search requests (default: 7)
77
- --tools [javascript,bash] comma seperated list
78
- --connect [address]: connect to server
79
- --serve [port]: start server on port
80
- e.g.
81
- claude.js --model claude-sonnet-4-0 --tokens 4000 --context 10000 --thinking 2000
82
-
83
- `);
84
- process.exit()
85
- }
86
-
87
- if (help) {
88
- printHelp();
89
- }
90
- const prompt = `
91
- 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.
92
- `.trim();
93
-
94
- const agent = new AgentManager({ name });
95
- agent.setup({
96
- prompt,
97
- api,
98
- options,
99
- toolsetMode,
100
- contextWindow
101
- });
102
- const tools = [];
103
- const toolset = agent.getToolset();
104
- if (toolset && args['tools']) {
105
- const addTools = args['tools'].split(',') || [];
106
- if (addTools.includes('javascript')) {
107
- let tool = genTools.get('javascript_interpreter');
108
- if (tool) {
109
- tools.push('javascript_interpreter');
110
- toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
111
- }
112
- }
113
- if (addTools.includes('bash')) {
114
- let tool = genTools.get('execute_bash_script');
115
- if (tool) {
116
- tools.push('execute_bash_script');
117
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
118
- }
119
- }
120
- }
121
-
122
- const cliIntro = `
123
- ${name} ${options.model}.
124
- - search ${options.search ? options.search.max_uses : 'disabled'}
125
- `.trim();
126
-
127
- const description = `
128
- Generic helper and smart AI for difficult tasks. Natural language, math and reasoning - the perfect jack of all trades
129
- `.trim();
130
-
131
- if (input === '' && serve) {
132
- agent.enableServer(name, description, serve);
133
- }
134
- if (input !== '') {
135
- // Direct input output
136
- const res = await agent.directCall(input);
137
- console.log(res);
138
- } else if(connect) {
139
- agent.attach(name, description, connect)
140
- } else if(!serve) {
141
- // Mix a cli with a server is a thing we need to test
142
- agent.startCli(cliIntro);
143
- }
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { parseArgs, readIn } from '@j-o-r/sh';
6
- import genTools from '../lib/genericToolset.js';
7
- import { systemInfo } from '../lib/fafs.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'gpt';
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /**
19
- * @type {import('lib/API/openai.com/reponses/text.js').OAOptions}
20
- */
21
- const options = {}
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'] || 'gpt-5';
26
- }
27
- // temperature is NOT available for o3 / 03-mini
28
- if (args['temperature']) {
29
- options.temperature = parseFloat(args['temperature']);
30
- }
31
- if (args['tokens']) {
32
- options.max_output_tokens = parseInt(args['tokens']);
33
- }
34
- if (args['top_p']) {
35
- options.top_p = parseFloat(args['top_p']);
36
- }
37
- if (args['search'] || true) {
38
- // always enable search
39
- // @ts-ignore
40
- options.search = args['search'] || 'medium';
41
- }
42
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
43
- if (reasoning) {
44
- // @ts-ignore
45
- options.reasoning= {effort: reasoning, summary: 'auto'}
46
- }
47
-
48
- const toolsetMode = 'auto';
49
- const contextWindow = args['context'] ? parseInt(args['context']) : 399000;
50
-
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
58
- --temperature [float] : default 0.4
59
- --model [gpt-5|gpt-5-mini|gpt-5-nano|gpt-4.1|o3|o3-mini|o4-mini|o1|o3-pro]
60
- --search [low|medium|high]
61
- --reasoning [low|medium|high]
62
- --tools [javascript,bash] comma seperated list
63
- e.g.
64
- gpt --model o3-mini --tokens 4000 --context 10000
65
-
66
- `);
67
- process.exit()
68
- }
69
-
70
- if (help) {
71
- printHelp();
72
- }
73
-
74
- const sys = await systemInfo();
75
- const prompt = `
76
- 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 safe Bash execution. For writing and reading files, stay in the current working folder. Provide clear, step-by-step responses, examples, and ensure safety compliance.
77
- ---env
78
- ${sys}
79
- ---
80
- `.trim();
81
-
82
- const agent = new AgentManager({ name });
83
- agent.setup({
84
- prompt,
85
- api,
86
- options,
87
- toolsetMode,
88
- contextWindow
89
- });
90
-
91
- const toolset = agent.getToolset();
92
- if (toolset) {
93
- const addTools = (args['tools']) ? args['tools'].split(',') : [];
94
- if (addTools.includes('javascript')) {
95
- let tool = genTools.get('javascript_interpreter');
96
- if (tool) {
97
- toolset.add('javascript_interpreter', tool.description, tool.parameters, tool.method);
98
- }
99
- }
100
- let tool = genTools.get('execute_bash_script');
101
- if (tool) {
102
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
103
- }
104
- }
105
- const cliIntro = `
106
- ${name} ${options.model}.
107
- - search ${options.search}
108
- - context: ${contextWindow}
109
- `.trim();
110
-
111
- const description = `
112
- Gateway coding assistant Agent for Bash, JavaScript (ESM/ESNext), and other languages. Handles execution, reading, creation, querying, explaining, and code help, with safety and folder restrictions.
113
- `.trim();
114
- if (input === '' && serve) {
115
- agent.enableServer('code', description, serve);
116
- }
117
- if (input !== '') {
118
- // Direct input output
119
- const res = await agent.directCall(input);
120
- console.log(res);
121
- } else if(connect) {
122
- agent.attach('code', description, connect)
123
- } else {
124
- agent.startCli(cliIntro);
125
- }
@@ -1,117 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { systemInfo } from '../lib/fafs.js';
6
- import { parseArgs, readIn } from '@j-o-r/sh';
7
- import toolsPool from '../lib/genericToolset.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'gpt'; // Using GPT API for general AI assistance, adjust if needed
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /**
19
- * @type {import('lib/API/openai.com/reponses/text.js').OAOptions}
20
- */
21
- const options = {}
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'] || 'gpt-5-mini';
26
- }
27
- // temperature is NOT available for o3 / 03-mini
28
- if (args['temperature']) {
29
- options.temperature = parseFloat(args['temperature']);
30
- }
31
- if (args['tokens']) {
32
- options.max_output_tokens = parseInt(args['tokens']);
33
- }
34
- if (args['top_p']) {
35
- options.top_p = parseFloat(args['top_p']);
36
- }
37
- // always enable search
38
- // @ts-ignore
39
- options.search = args['search'] || 'medium';
40
-
41
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
42
-
43
- if (reasoning) {
44
- // @ts-ignore
45
- options.reasoning = { effort: reasoning, summary: 'auto' }
46
- }
47
-
48
- const toolsetMode = 'auto';
49
- const contextWindow = args['context'] ? parseInt(args['context']) : 399000;
50
-
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
58
- --temperature [float] : default 0.4
59
- --model [gpt-5|gpt-5-mini|gpt-5-nano|gpt-4.1|o3|o3-mini|o4-mini|o1|o3-pro]
60
- --reasoning [low|medium|high]
61
- e.g.
62
- gpt --model o3-mini --tokens 4000 --context 10000
63
-
64
- `);
65
- process.exit()
66
- }
67
-
68
- if (help) {
69
- printHelp();
70
- }
71
- const sys = await systemInfo();
72
-
73
- // You are an AI note-keeping assistant for Markdown notes in extended context. Use/create 'notes' folder in cwd. Search via tools like grep. Create/update/delete .md files safely. Goals: track progress, manage todos, capture requirements, document processes, store links/bookmarks/remarks. Respond concisely, step-by-step, no unnecessary follow-ups.
74
- const prompt = `
75
- You are an AI note-keeping assistant for Markdown notes. Use/create 'notes' folder in cwd. Search via grep. Safely create/update/delete .md files. Goals: track progress, manage todos, capture requirements, document processes, store links/remarks. Respond concisely, step-by-step; organize in logical folders, no unnecessary follow-ups.
76
- ---env
77
- ${sys}
78
- ---
79
- `.trim();
80
- const agent = new AgentManager({ name });
81
- agent.setup({
82
- prompt,
83
- api,
84
- options,
85
- toolsetMode,
86
- contextWindow
87
- });
88
- const toolset = agent.getToolset();
89
-
90
- if (toolset) {
91
- let tool = toolsPool.get('execute_bash_script');
92
- if (tool) {
93
- toolset.add('execute_bash_script', tool.description, tool.parameters, tool.method);
94
- }
95
- }
96
-
97
- const cliIntro = `
98
- ${name} ${options.model}.
99
- - search ${options.search}
100
- - context: ${contextWindow}
101
- `.trim();
102
- const description = `
103
- AI-assisted note-keeping tool for Markdown notes. Support: search, create, update, delete. Track progress, todos, requirements, docs, links, bookmarks, remarks. Use as extended memory for task progress, decisions, state. On startup, query notes for last known state/context. Save notes regularly.
104
- `.trim();
105
-
106
- if (input === '' && serve) {
107
- agent.enableServer('memory', description, serve);
108
- }
109
- if (input !== '') {
110
- // Direct input output
111
- const res = await agent.directCall(input);
112
- console.log(res);
113
- } else if (connect) {
114
- agent.attach('memory', description, connect)
115
- } else {
116
- agent.startCli(cliIntro);
117
- }
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env node
2
- import { fileURLToPath } from 'url';
3
- import path from 'path';
4
- import AgentManager from '../lib/AgentManager.js';
5
- import { parseArgs, readIn } from '@j-o-r/sh';
6
- import genTools from '../lib/genericToolset.js';
7
- import { systemInfo } from '../lib/fafs.js';
8
-
9
- const name = path.basename(fileURLToPath(import.meta.url), path.extname(fileURLToPath(import.meta.url)));
10
- const api = 'grok';
11
-
12
- const input = await readIn();
13
- const args = parseArgs();
14
- const help = args['help'] || false;
15
- const connect = args['connect'] ? args['connect'] : undefined;
16
- const serve = args['serve'] ? parseInt(args['serve']) : undefined;
17
-
18
- /** @type {import('lib/API/x.ai/text.js').XOptions} */
19
- const options = {}
20
- // Set properties only if provided via command line (except model which has default)
21
- if (args['model'] || true) { // model gets default value
22
- // @ts-ignore
23
- options.model = args['model'] || 'grok-code-fast-1';
24
- }
25
- if (args['temperature']) {
26
- options.temperature = parseFloat(args['temperature']);
27
- }
28
- if (args['tokens']) {
29
- options.max_completion_tokens = parseInt(args['tokens']);
30
- }
31
- if (args['top_p']) {
32
- options.top_p = parseFloat(args['top_p']);
33
- }
34
- options.search_parameters = { mode: 'auto' }
35
- const reasoning = args['reasoning'] ? args['reasoning'] : null;
36
- if (reasoning) {
37
- // @ts-ignore
38
- options.reasoning_effort = reasoning
39
- }
40
-
41
- const toolsetMode = 'auto';
42
- const contextWindow = args['context'] ? parseInt(args['context']) : 250000;
43
-
44
- // Copy from the generic toolset
45
- function printHelp() {
46
- console.log(`
47
- '${name} --help' You are looking at it.
48
- '
49
- OPTIONS:
50
- --tokens [number]: max generated tokens
51
- --context [number] : truncate message history to context-windows size default 130000
52
- --temperature [float] : -2 / +2
53
- --model [grok-4|grok-3|grok-3-mini|grok-3-mini-fast|grok-code-fast-1]
54
- --top_p [float]: number > 0, 0.1 means no top_p
55
- --reasoning [low|high]
56
- --tools [javascript,bash] comma seperated list
57
- e.g.
58
- grok.js --model grok-3-mini --tokens 4000 --context 10000
59
-
60
- `);
61
- process.exit()
62
- }
63
-
64
- if (help) {
65
- printHelp();
66
- }
67
-
68
- const sys = await systemInfo();
69
- const prompt = `
70
- 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 safe Bash execution. For writing and reading files, stay in the current working folder. Provide clear, step-by-step responses, examples, and ensure safety compliance.
71
- Update your 'memory' frequently.
72
- ---env
73
- ${sys}
74
- ---
75
- `.trim();
76
- const agent = new AgentManager({ name });
77
- agent.setup({
78
- prompt,
79
- api,
80
- options,
81
- toolsetMode,
82
- contextWindow
83
- });
84
- const toolset = agent.getToolset();
85
- if (toolset) {
86
- const addTools = (args['tools']) ? args['tools'].split(',') : ['bash'];
87
- if (addTools.includes('javascript')) {
88
- agent.addGenericToolcall('javascript_interpreter');
89
- }
90
- if (addTools.includes('bash')) {
91
- agent.addGenericToolcall('execute_bash_script');
92
- }
93
- }
94
- const cliIntro = `
95
- ${name} ${options.model}.
96
- - search ${options.search_parameters.mode}
97
- - context: ${contextWindow}
98
- `.trim();
99
- const description = `
100
- Gateway to a specialized coding assistant for Bash, JavaScript (ESM/ESNext), and other languages. Handles execution, reading, creation, querying, explaining, and code help, with safety and folder restrictions.
101
- `.trim();
102
-
103
- if (input === '' && serve) {
104
- agent.enableServer('code', description, serve);
105
- }
106
- if (input !== '') {
107
- // Direct input output
108
- const res = await agent.directCall(input);
109
- console.log(res);
110
- } else if (connect) {
111
- agent.attach('code', description, connect)
112
- } else {
113
- agent.startCli(cliIntro);
114
- }