@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,141 +0,0 @@
|
|
|
1
|
-
# Prompt Class
|
|
2
|
-
|
|
3
|
-
Source: \`lib/Prompt.js\`
|
|
4
|
-
|
|
5
|
-
The \`Prompt\` class is an EventEmitter-based manager for standardized AI conversation messages. It supports multi-modal content (text, images, audio), tool/function calls, token counting, automatic truncation, and adapters for different LLM providers (OpenAI, xAI, Anthropic).
|
|
6
|
-
|
|
7
|
-
## Key Features
|
|
8
|
-
- Uniform message format across providers.
|
|
9
|
-
- Context window management with truncation.
|
|
10
|
-
- Toolset integration for function calling.
|
|
11
|
-
- Event-driven (add, start, finished, tool_request, etc.).
|
|
12
|
-
- Sticky system prompts preserved on reset/truncate.
|
|
13
|
-
|
|
14
|
-
## Dependencies
|
|
15
|
-
- \`gpt-3-encoder\` for token counting.
|
|
16
|
-
- \`node:events\` EventEmitter.
|
|
17
|
-
- \`./promptHelpers.js\` for tool pruning.
|
|
18
|
-
|
|
19
|
-
## Message Structure
|
|
20
|
-
```js
|
|
21
|
-
{
|
|
22
|
-
role: "system" | "assistant" | "user" | "tool" | "log" | "reasoning",
|
|
23
|
-
content: Content[],
|
|
24
|
-
name?: string,
|
|
25
|
-
sticky?: boolean, // Preserve on reset
|
|
26
|
-
ts?: number // Timestamp
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Content Types
|
|
31
|
-
| Type | Role Constraints | Structure |
|
|
32
|
-
|------|------------------|-----------|
|
|
33
|
-
| `text` | system/assistant/user | `{ type: "text", text: string }` |
|
|
34
|
-
| `image_url` | user | `{ type: "image_url", url: string \| data:URL }` |
|
|
35
|
-
| `audio_url` | user | `{ type: "audio_url", url: string \| data:URL }` |
|
|
36
|
-
| `function_request` | assistant | `{ type: "function_request", function_request: { name: string, id: string, call_id?: string, parameters: string (JSON) } }` |
|
|
37
|
-
| `function_response` | tool | `{ type: "function_response", function_response: { name: string, id: string, call_id?: string, response: string (JSON) } }` |
|
|
38
|
-
|
|
39
|
-
## Record Structure (API Logs)
|
|
40
|
-
```js
|
|
41
|
-
{
|
|
42
|
-
id: string,
|
|
43
|
-
isoDate: string,
|
|
44
|
-
duration: number (ms),
|
|
45
|
-
environment: string,
|
|
46
|
-
model: string,
|
|
47
|
-
tokensIn: number,
|
|
48
|
-
tokensOut: number
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Constants
|
|
53
|
-
```js
|
|
54
|
-
const MESSAGE_ROLES = { SYSTEM: "system", ASSISTANT: "assistant", ... };
|
|
55
|
-
const MESSAGE_TYPES = { TEXT: "text", IMAGE_URL: "image_url", ... };
|
|
56
|
-
const EVENTS = { start: "start", finished: "finished", tool_request: "tool_request", ... };
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Usage Example
|
|
60
|
-
```js
|
|
61
|
-
import { Prompt, ToolSet } from '@j-o-r/hello-dave';
|
|
62
|
-
import { openaiText } from './API/openai.com/text.js'; // Adapter example
|
|
63
|
-
|
|
64
|
-
const prompt = new Prompt(128000); // Context window
|
|
65
|
-
prompt.setAdaptor(openaiText, new ToolSet(), { model: "gpt-4o" });
|
|
66
|
-
|
|
67
|
-
prompt.add("system", "You are a helpful assistant.", true);
|
|
68
|
-
const response = await prompt.call("Hello!");
|
|
69
|
-
console.log(response); // Assistant response
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Properties
|
|
73
|
-
| Name | Type | Description |
|
|
74
|
-
|------|------|-------------|
|
|
75
|
-
| `contextLength` | `number` | Max tokens (getter) |
|
|
76
|
-
| `messages` | `Message[]` | Copy of messages (getter/setter validates/imports) |
|
|
77
|
-
| `length` | `number` | Message count |
|
|
78
|
-
| `system_prompt` | `string` | System message text (throws if missing) |
|
|
79
|
-
| `hasSystemprompt` | `boolean` | System prompt present? |
|
|
80
|
-
| `toolset` | `ToolSet \| void` | Current toolset |
|
|
81
|
-
| `EVENTS` | `object` | Frozen event names |
|
|
82
|
-
|
|
83
|
-
## Methods
|
|
84
|
-
|
|
85
|
-
### Constructor
|
|
86
|
-
```js
|
|
87
|
-
new Prompt(contextWindow?: number)
|
|
88
|
-
```
|
|
89
|
-
- `contextWindow = 0`: One-shot (no history buildup).
|
|
90
|
-
|
|
91
|
-
### Setup
|
|
92
|
-
- `setAdaptor(requestHandler, toolset?: ToolSet, options?)`: Bind AI provider.
|
|
93
|
-
- `toolsetFunctions()`: `string[]` of available tools.
|
|
94
|
-
|
|
95
|
-
### Adding Messages
|
|
96
|
-
- `add(role: Roles, text: string, sticky = false)`: Text message.
|
|
97
|
-
- `addMultiModal(role: Roles, content: Content[], sticky = false)`: Multi-modal.
|
|
98
|
-
- Validates role/content, order (system first/sticky), emits `message`.
|
|
99
|
-
|
|
100
|
-
### Conversation Flow
|
|
101
|
-
- `call(content: string \| Content[])`: Add user input, call adapter, return text response. Emits `start`, `finished`.
|
|
102
|
-
- `triggerRequest()`: Auto-trigger if last message is user/tool (for tools first).
|
|
103
|
-
|
|
104
|
-
### Management
|
|
105
|
-
- `reset()`: Remove non-sticky, return removed. Emits `reset`.
|
|
106
|
-
- `truncate()`: Prune tools, remove old user-assistant blocks to fit context. Emits `truncated`.
|
|
107
|
-
- `countTokens(str?: string)`: Tokens in string or last total.
|
|
108
|
-
- `contentToString(content)`: Concat text from content.
|
|
109
|
-
- `getLastMessage()`: Last message.
|
|
110
|
-
|
|
111
|
-
### Records & Info
|
|
112
|
-
- `addRecord(record)` / `addRecords(records[])`: Log API usage, update tokens, warn if over limit.
|
|
113
|
-
- `templateRecord()`: Empty record.
|
|
114
|
-
- `info()`: Debug string (cwd, tools, context, tokens).
|
|
115
|
-
|
|
116
|
-
## Events
|
|
117
|
-
Emitted via `EventEmitter`:
|
|
118
|
-
|
|
119
|
-
| Event | Triggered When | Data |
|
|
120
|
-
|-------|----------------|------|
|
|
121
|
-
| `message` | Message added | `Message` |
|
|
122
|
-
| `start` / `retrigger` / `finished` | Request lifecycle | `true` |
|
|
123
|
-
| `record` | Record added | `Record` |
|
|
124
|
-
| `truncated` / `reset` | History altered | Event name |
|
|
125
|
-
| `tool_request` / `tool_response` / `tool_error` | Tool lifecycle | Tool data |
|
|
126
|
-
| `error` / `warning` | Issues | Error/Warning |
|
|
127
|
-
|
|
128
|
-
## Validation
|
|
129
|
-
- Strict checks on message roles/types/content.
|
|
130
|
-
- Records must have all fields.
|
|
131
|
-
- Order: System first/sticky sequential.
|
|
132
|
-
|
|
133
|
-
## Truncation Details
|
|
134
|
-
1. Prune resolved tool calls (keep last per ID).
|
|
135
|
-
2. Sum sticky tokens.
|
|
136
|
-
3. From end: Remove full user-assistant blocks exceeding window.
|
|
137
|
-
|
|
138
|
-
## Integration Notes
|
|
139
|
-
- Adapters handle provider-specific formatting (e.g., OpenAI, xAI).
|
|
140
|
-
- Tools execute automatically in `triggerRequest`.
|
|
141
|
-
- Supports reasoning role (xAI-specific).
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# Prompt Class
|
|
2
|
-
|
|
3
|
-
Source: \`lib/Prompt.js\`
|
|
4
|
-
|
|
5
|
-
The \`Prompt\` class is an EventEmitter-based manager for standardized AI conversation messages. It supports multi-modal content (text, images, audio), tool/function calls, token counting, automatic truncation, and adapters for different LLM providers (OpenAI, xAI, Anthropic).
|
|
6
|
-
|
|
7
|
-
## Key Features
|
|
8
|
-
- Uniform message format across providers.
|
|
9
|
-
- Context window management with truncation.
|
|
10
|
-
- Toolset integration for function calling.
|
|
11
|
-
- Event-driven (add, start, finished, tool_request, etc.).
|
|
12
|
-
- Sticky system prompts preserved on reset/truncate.
|
|
13
|
-
|
|
14
|
-
## Dependencies
|
|
15
|
-
- \`gpt-3-encoder\` for token counting.
|
|
16
|
-
- \`node:events\` EventEmitter.
|
|
17
|
-
- \`./promptHelpers.js\` for tool pruning.
|
|
18
|
-
|
|
19
|
-
## Message Structure
|
|
20
|
-
```js
|
|
21
|
-
{
|
|
22
|
-
role: "system" | "assistant" | "user" | "tool" | "log" | "reasoning",
|
|
23
|
-
content: Content[],
|
|
24
|
-
name?: string,
|
|
25
|
-
sticky?: boolean, // Preserve on reset
|
|
26
|
-
ts?: number // Timestamp
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Content Types
|
|
31
|
-
| Type | Role Constraints | Structure |
|
|
32
|
-
|------|------------------|-----------|
|
|
33
|
-
| `text` | system/assistant/user | `{ type: "text", text: string }` |
|
|
34
|
-
| `image_url` | user | `{ type: "image_url", url: string \| data:URL }` |
|
|
35
|
-
| `audio_url` | user | `{ type: "audio_url", url: string \| data:URL }` |
|
|
36
|
-
| `function_request` | assistant | `{ type: "function_request", function_request: { name: string, id: string, call_id?: string, parameters: string (JSON) } }` |
|
|
37
|
-
| `function_response` | tool | `{ type: "function_response", function_response: { name: string, id: string, call_id?: string, response: string (JSON) } }` |
|
|
38
|
-
|
|
39
|
-
## Record Structure (API Logs)
|
|
40
|
-
```js
|
|
41
|
-
{
|
|
42
|
-
id: string,
|
|
43
|
-
isoDate: string,
|
|
44
|
-
duration: number (ms),
|
|
45
|
-
environment: string,
|
|
46
|
-
model: string,
|
|
47
|
-
tokensIn: number,
|
|
48
|
-
tokensOut: number
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Constants
|
|
53
|
-
```js
|
|
54
|
-
const MESSAGE_ROLES = { SYSTEM: "system", ASSISTANT: "assistant", ... };
|
|
55
|
-
const MESSAGE_TYPES = { TEXT: "text", IMAGE_URL: "image_url", ... };
|
|
56
|
-
const EVENTS = { start: "start", finished: "finished", tool_request: "tool_request", ... };
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Usage Example
|
|
60
|
-
```js
|
|
61
|
-
import Prompt from "./Prompt.js";
|
|
62
|
-
import { openaiText } from "./API/openai.com/text.js"; // Adapter example
|
|
63
|
-
import ToolSet from "./ToolSet.js";
|
|
64
|
-
|
|
65
|
-
const prompt = new Prompt(128000); // Context window
|
|
66
|
-
prompt.setAdaptor(openaiText, new ToolSet(), { model: "gpt-4o" });
|
|
67
|
-
|
|
68
|
-
prompt.add("system", "You are a helpful assistant.", true);
|
|
69
|
-
const response = await prompt.call("Hello!");
|
|
70
|
-
console.log(response); // Assistant response
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Properties
|
|
74
|
-
| Name | Type | Description |
|
|
75
|
-
|------|------|-------------|
|
|
76
|
-
| `contextLength` | `number` | Max tokens (getter) |
|
|
77
|
-
| `messages` | `Message[]` | Copy of messages (getter/setter validates/imports) |
|
|
78
|
-
| `length` | `number` | Message count |
|
|
79
|
-
| `system_prompt` | `string` | System message text (throws if missing) |
|
|
80
|
-
| `hasSystemprompt` | `boolean` | System prompt present? |
|
|
81
|
-
| `toolset` | `ToolSet \| void` | Current toolset |
|
|
82
|
-
| `EVENTS` | `object` | Frozen event names |
|
|
83
|
-
|
|
84
|
-
## Methods
|
|
85
|
-
|
|
86
|
-
### Constructor
|
|
87
|
-
```js
|
|
88
|
-
new Prompt(contextWindow?: number)
|
|
89
|
-
```
|
|
90
|
-
- `contextWindow = 0`: One-shot (no history buildup).
|
|
91
|
-
|
|
92
|
-
### Setup
|
|
93
|
-
- `setAdaptor(requestHandler, toolset?: ToolSet, options?)`: Bind AI provider.
|
|
94
|
-
- `toolsetFunctions()`: `string[]` of available tools.
|
|
95
|
-
|
|
96
|
-
### Adding Messages
|
|
97
|
-
- `add(role: Roles, text: string, sticky = false)`: Text message.
|
|
98
|
-
- `addMultiModal(role: Roles, content: Content[], sticky = false)`: Multi-modal.
|
|
99
|
-
- Validates role/content, order (system first/sticky), emits `message`.
|
|
100
|
-
|
|
101
|
-
### Conversation Flow
|
|
102
|
-
- `call(content: string \| Content[])`: Add user input, call adapter, return text response. Emits `start`, `finished`.
|
|
103
|
-
- `triggerRequest()`: Auto-trigger if last message is user/tool (for tools first).
|
|
104
|
-
|
|
105
|
-
### Management
|
|
106
|
-
- `reset()`: Remove non-sticky, return removed. Emits `reset`.
|
|
107
|
-
- `truncate()`: Prune tools, remove old user-assistant blocks to fit context. Emits `truncated`.
|
|
108
|
-
- `countTokens(str?: string)`: Tokens in string or last total.
|
|
109
|
-
- `contentToString(content)`: Concat text from content.
|
|
110
|
-
- `getLastMessage()`: Last message.
|
|
111
|
-
|
|
112
|
-
### Records & Info
|
|
113
|
-
- `addRecord(record)` / `addRecords(records[])`: Log API usage, update tokens, warn if over limit.
|
|
114
|
-
- `templateRecord()`: Empty record.
|
|
115
|
-
- `info()`: Debug string (cwd, tools, context, tokens).
|
|
116
|
-
|
|
117
|
-
## Events
|
|
118
|
-
Emitted via `EventEmitter`:
|
|
119
|
-
|
|
120
|
-
| Event | Triggered When | Data |
|
|
121
|
-
|-------|----------------|------|
|
|
122
|
-
| `message` | Message added | `Message` |
|
|
123
|
-
| `start` / `retrigger` / `finished` | Request lifecycle | `true` |
|
|
124
|
-
| `record` | Record added | `Record` |
|
|
125
|
-
| `truncated` / `reset` | History altered | Event name |
|
|
126
|
-
| `tool_request` / `tool_response` / `tool_error` | Tool lifecycle | Tool data |
|
|
127
|
-
| `error` / `warning` | Issues | Error/Warning |
|
|
128
|
-
|
|
129
|
-
## Validation
|
|
130
|
-
- Strict checks on message roles/types/content.
|
|
131
|
-
- Records must have all fields.
|
|
132
|
-
- Order: System first/sticky sequential.
|
|
133
|
-
|
|
134
|
-
## Truncation Details
|
|
135
|
-
1. Prune resolved tool calls (keep last per ID).
|
|
136
|
-
2. Sum sticky tokens.
|
|
137
|
-
3. From end: Remove full user-assistant blocks exceeding window.
|
|
138
|
-
|
|
139
|
-
## Integration Notes
|
|
140
|
-
- Adapters handle provider-specific formatting (e.g., OpenAI, xAI).
|
|
141
|
-
- Tools execute automatically in `triggerRequest`.
|
|
142
|
-
- Supports reasoning role (xAI-specific).
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# Syntax Validation in Generic Tools
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
**Integration Complete**: `lib/genericToolset.js` now includes **automatic JS syntax validation** in `write_file` **and a new `syntax_check` tool** using `./utils/syntax_check.sh` for multi-language support (JS/Python/Bash/JSON). Prevents invalid code, resolves escaping issues, auto `chmod +x` shebangs. Post-write errors prompt LLM retries.
|
|
5
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
6
|
-
|
|
7
|
-
**Key Benefits**:
|
|
8
|
-
- **JS Safety**: `node --check` (in `write_file`); full multi-lang in `syntax_check`.
|
|
9
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
10
|
-
- **Executable Prep**: Auto `chmod +x`.
|
|
11
|
-
- **Retry-Friendly**: Descriptive errors + previews.
|
|
12
|
-
- **Generic Access**: `toolsetMode: 'auto'` loads both.
|
|
13
|
-
|
|
14
|
-
**Commit History** (relevant):
|
|
15
|
-
- `3c8e1ae`: Initial `read_file`/`write_file`.
|
|
16
|
-
- Recent: JS validation + `syntax_check` tool.
|
|
17
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
18
|
-
|
|
19
|
-
## write_file Tool Updates
|
|
20
|
-
|
|
21
|
-
### Description (Updated)
|
|
22
|
-
```
|
|
23
|
-
Write raw content to a file strictly within the current working directory (CWD). Paths must be relative (no leading /, no ..). Content written as-is (no escaping). **AUTO-VALIDATES JS FILES** with `node --check`; chmod +x shebangs. Retries syntax errors force LLM fix.
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Examples
|
|
27
|
-
**Success** (CLI/Agent):
|
|
28
|
-
```bash
|
|
29
|
-
echo 'const x = \`hi\`; console.log(x);' | agent.directCall("Use write_file on test.js with this content")
|
|
30
|
-
# Returns: "Successfully wrote to 'test.js' (42 bytes). ✓ JS syntax OK"
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Failure + Retry**:
|
|
34
|
-
```javascript
|
|
35
|
-
// LLM generates invalid:
|
|
36
|
-
const msg = `Hello ${name`; // Missing `
|
|
37
|
-
```
|
|
38
|
-
**Error**:
|
|
39
|
-
```
|
|
40
|
-
❌ JS SYNTAX ERROR in 'test.js' (node --check failed):
|
|
41
|
-
SyntaxError: Unexpected token '}'
|
|
42
|
-
|
|
43
|
-
PREVIEW:
|
|
44
|
-
const msg = `Hello ${name
|
|
45
|
-
...
|
|
46
|
-
|
|
47
|
-
... Fix escaping/backticks in template literals (use \\\\` for \` in JS strings) and retry.
|
|
48
|
-
```
|
|
49
|
-
**LLM Sees → Fixes**: Uses `"Hello \${name}"` or proper `` \` ``.
|
|
50
|
-
|
|
51
|
-
**Shebang**:
|
|
52
|
-
```javascript
|
|
53
|
-
content: '#!/usr/bin/env node\nconst hello = () => console.log("Hi");'
|
|
54
|
-
# Returns: "... ✓ JS syntax OK ✓ chmod +x"
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## New: syntax_check Tool
|
|
58
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
59
|
-
|
|
60
|
-
**Description**:
|
|
61
|
-
```
|
|
62
|
-
Validate syntax of a file (JS, Python, Bash/Sh, JSON). Detects language from extension/shebang. Uses native checkers... Exit 1 on fail.
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Parameters
|
|
66
|
-
```json
|
|
67
|
-
{
|
|
68
|
-
"type": "object",
|
|
69
|
-
"properties": { "file": { "type": "string" } },
|
|
70
|
-
"required": ["file"]
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Examples
|
|
75
|
-
**Agent Call**:
|
|
76
|
-
```
|
|
77
|
-
agent.directCall("Use syntax_check on test.js") → "🔍 Validating test.js (lang: js)\n✅ JS OK\n✅ Syntax validation passed for test.js"
|
|
78
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**Multi-Lang**:
|
|
82
|
-
- **Python**: `syntax_check script.py` → `✅ Python OK`
|
|
83
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
84
|
-
- **Bash**: `syntax_check script.sh` → `✅ Bash OK` ( + Shellcheck if avail.)
|
|
85
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
86
|
-
- **JSON**: `syntax_check config.json` → `✅ JSON OK`
|
|
87
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
88
|
-
- **Fail**: Invalid JSON → `❌ JSON invalid`
|
|
89
|
-
|
|
90
|
-
**Integration**: Post-`write_file`, agent can call `syntax_check(file)` for non-JS.
|
|
91
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
92
|
-
|
|
93
|
-
## utils/syntax_check.sh (Underlying Script)
|
|
94
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
95
|
-
[Full source in prior doc]. Detects lang, runs checkers. Standalone/executable.
|
|
96
|
-
|
|
97
|
-
### Usage (Direct)
|
|
98
|
-
```bash
|
|
99
|
-
./utils/syntax_check.sh test.js # ✅ JS OK
|
|
100
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
101
|
-
./utils/syntax_check.sh bad.py # ❌ Python syntax error
|
|
102
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Agent Workflow Example
|
|
106
|
-
```
|
|
107
|
-
User: "Create & validate test.js: const add = (a,b) => a+b; export {add};"
|
|
108
|
-
Agent:
|
|
109
|
-
1. write_file(test.js, content) → ✓ JS OK
|
|
110
|
-
2. syntax_check(test.js) → ✅ (redundant but confirms)
|
|
111
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Cross-Links
|
|
115
|
-
- [ToolSet](../toolset.md#generic-tools) ← [Linked below](#update-to-toolsetmd)
|
|
116
|
-
- [AgentManager](../agent-manager.md)
|
|
117
|
-
- Source: [lib/genericToolset.js](../lib/genericToolset.js), [utils/syntax_check.sh](../utils/syntax_check.sh)
|
|
118
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
119
|
-
|
|
120
|
-
**Updated**: March 27, 2026 (syntax_check integrated).
|
|
121
|
-
**Path Note**: Uses `__dirname` for utils/; resolves files to `process.cwd()`. See [path-resolution-best-practices.md](path-resolution-best-practices.md).
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Syntax Validation in Generic Tools
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Recent enhancements to `lib/genericToolset.js` introduce **automatic syntax validation** for files written via the `write_file` tool. This prevents invalid code deployment, resolves common **escaping issues** in JavaScript, and supports shebang executables. Validation occurs **post-write**, throwing descriptive errors to prompt LLM retries/fixes.
|
|
5
|
-
|
|
6
|
-
**Key Benefits**:
|
|
7
|
-
- **JS Safety**: `node --check` catches syntax errors (e.g., unescaped backticks in template literals).
|
|
8
|
-
- **Executable Prep**: Auto `chmod +x` for shebangs.
|
|
9
|
-
- **Retry-Friendly**: Errors include code preview + fix hints, enabling agent self-correction.
|
|
10
|
-
- **No Overhead**: Only for JS/shebang files; fast native checks.
|
|
11
|
-
|
|
12
|
-
**Commit History** (relevant):
|
|
13
|
-
- `3c8e1ae`: Added `read_file`, `write_file` with initial path security.
|
|
14
|
-
- Recent refinements: Syntax check + escaping guidance.
|
|
15
|
-
|
|
16
|
-
## write_file Tool Updates (`lib/genericToolset.js`)
|
|
17
|
-
|
|
18
|
-
### Updated Description
|
|
19
|
-
```
|
|
20
|
-
Write raw content to a file strictly within the current working directory (CWD). Paths must be relative (no leading /, no ..). Content written as-is (no escaping). **AUTO-VALIDATES JS FILES** with `node --check`; chmod +x shebangs. Retries syntax errors force LLM fix.
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Validation Logic
|
|
24
|
-
```javascript
|
|
25
|
-
// After fs.writeFile(resolvedPath, content, 'utf8');
|
|
26
|
-
const ext = path.extname(file).toLowerCase();
|
|
27
|
-
const isJS = ext === '.js' || content.startsWith('#!/usr/bin/env node');
|
|
28
|
-
const hasShebang = content.startsWith('#!');
|
|
29
|
-
|
|
30
|
-
if (isJS) {
|
|
31
|
-
try {
|
|
32
|
-
await SH`node --check ${[resolvedPath]}`.run();
|
|
33
|
-
validationMsg = ' ✓ JS syntax OK';
|
|
34
|
-
} catch (e) {
|
|
35
|
-
const errPreview = content.slice(0, 1000).split('\\n').slice(0, 20).join('\\n');
|
|
36
|
-
throw new Error(`❌ JS SYNTAX ERROR in '${file}' (node --check failed):
|
|
37
|
-
${e.message}
|
|
38
|
-
|
|
39
|
-
PREVIEW:
|
|
40
|
-
${errPreview}
|
|
41
|
-
|
|
42
|
-
... Fix escaping/backticks in template literals (use \\\\` for \` in JS strings) and retry.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (hasShebang) {
|
|
46
|
-
await SH`chmod +x ${[resolvedPath]}`.run();
|
|
47
|
-
validationMsg += ' ✓ chmod +x';
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Escaping Issues Resolved
|
|
52
|
-
- **Backticks in JS Strings**: Common LLM error—generates `` `hi` `` inside strings without escaping. Hint: `use \\\\` for \` in JS strings`.
|
|
53
|
-
- **Template Literals**: Ensures `` \` ${var} \` `` is valid; catches mismatched quotes.
|
|
54
|
-
- **Raw Content**: Verbatim write (newlines, `$|<> & " '\\`` preserved), but syntax-enforced.
|
|
55
|
-
- **No False Positives**: Only triggers on `.js` ext or Node shebang; preview limits noise.
|
|
56
|
-
|
|
57
|
-
**Example Error (LLM Sees)**:
|
|
58
|
-
```
|
|
59
|
-
❌ JS SYNTAX ERROR in 'test.js' (node --check failed):
|
|
60
|
-
SyntaxError: Unexpected token `
|
|
61
|
-
|
|
62
|
-
PREVIEW:
|
|
63
|
-
const msg = `Hello ${name}
|
|
64
|
-
...
|
|
65
|
-
|
|
66
|
-
... Fix escaping/backticks in template literals (use \\\\` for \` in JS strings) and retry.
|
|
67
|
-
```
|
|
68
|
-
- **LLM Fix**: Rewrites with `"Hello \${name}"` or proper `` \` `` nesting.
|
|
69
|
-
|
|
70
|
-
### Usage in Agents
|
|
71
|
-
```javascript
|
|
72
|
-
agent.addGenericToolcall('write_file'); // Auto-includes validation
|
|
73
|
-
await agent.directCall("Write test.js: const x = `hi`; console.log(x);"); // Passes
|
|
74
|
-
// Fails + retries: "Write test.js: const x = `hi; console.log(x);" → SyntaxError → Fix
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Multi-Language Syntax Validation (utils/syntax_check.sh)
|
|
78
|
-
|
|
79
|
-
**New Utility**: `./utils/syntax_check.sh` – Standalone script for **JS, Python, Bash, JSON**. Detects lang via ext/shebang, runs native checkers. Exit 0=OK, 1=error. Integrates as future `write_file` extension or new tool.
|
|
80
|
-
|
|
81
|
-
### Features
|
|
82
|
-
| Lang | Checker | Optional | Notes |
|
|
83
|
-
|------|---------|----------|-------|
|
|
84
|
-
| **JS** | `node --check` | - | Syntax only (no runtime). |
|
|
85
|
-
| **Python** | `python3 -m py_compile` | - | Bytecode compile. |
|
|
86
|
-
| **Bash/Sh** | `bash -n` + `shellcheck` | Shellcheck | Static + linter. |
|
|
87
|
-
| **JSON** | `node -e JSON.parse(...)` | - | Parse validation. |
|
|
88
|
-
| **Unknown** | Skip | - | Non-fatal. |
|
|
89
|
-
|
|
90
|
-
### Usage
|
|
91
|
-
```bash
|
|
92
|
-
./utils/syntax_check.sh path/to/file.js # 🔍 JS OK / ❌ error
|
|
93
|
-
./utils/syntax_check.sh script.py --verbose # Extra output
|
|
94
|
-
# Future: --fix (auto-retry via agent?)
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Script Source (utils/syntax_check.sh)
|
|
98
|
-
```bash
|
|
99
|
-
#!/bin/bash
|
|
100
|
-
set -euo pipefail
|
|
101
|
-
# Full script: Detects lang, validates, echoes status.
|
|
102
|
-
# Created: March 27, 2026
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Integration Proposal: New Tool `syntax_check`
|
|
106
|
-
Add to `ToolSet` / `genericToolset.js`:
|
|
107
|
-
```javascript
|
|
108
|
-
tools.add('syntax_check', 'Validate file syntax (JS/Py/Bash/JSON).', {
|
|
109
|
-
type: 'object',
|
|
110
|
-
properties: { file: {type: 'string'} },
|
|
111
|
-
required: ['file']
|
|
112
|
-
}, async ({file}) => {
|
|
113
|
-
const script = path.resolve(__dirname, '..', 'utils', 'syntax_check.sh');
|
|
114
|
-
return await SH`${script} "${file}"`.run();
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
- **Post-write Call**: `write_file` → `syntax_check` → LLM fix loop.
|
|
118
|
-
- **Extend write_file**: Run `./syntax_check.sh "$file"` after JS check.
|
|
119
|
-
|
|
120
|
-
**Cross-Links**:
|
|
121
|
-
- [ToolSet](../toolset.md#generic-tools)
|
|
122
|
-
- [AgentManager](../agent-manager.md#custom-tools--generics)
|
|
123
|
-
- Source: [lib/genericToolset.js](../lib/genericToolset.js)
|
|
124
|
-
|
|
125
|
-
**Updated**: March 27, 2026
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Syntax Validation in Generic Tools
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Recent enhancements to `lib/genericToolset.js` introduce **automatic syntax validation** for files written via the `write_file` tool. This prevents invalid code deployment, resolves common **escaping issues** in JavaScript, and supports shebang executables. Validation occurs **post-write**, throwing descriptive errors to prompt LLM retries/fixes.
|
|
5
|
-
|
|
6
|
-
**Key Benefits**:
|
|
7
|
-
- **JS Safety**: `node --check` catches syntax errors (e.g., unescaped backticks in template literals).
|
|
8
|
-
- **Executable Prep**: Auto `chmod +x` for shebangs.
|
|
9
|
-
- **Retry-Friendly**: Errors include code preview + fix hints, enabling agent self-correction.
|
|
10
|
-
- **No Overhead**: Only for JS/shebang files; fast native checks.
|
|
11
|
-
|
|
12
|
-
**Commit History** (relevant):
|
|
13
|
-
- `3c8e1ae`: Added `read_file`, `write_file` with initial path security.
|
|
14
|
-
- Recent refinements: Syntax check + escaping guidance.
|
|
15
|
-
|
|
16
|
-
## write_file Tool Updates (`lib/genericToolset.js`)
|
|
17
|
-
|
|
18
|
-
### Updated Description
|
|
19
|
-
```
|
|
20
|
-
Write raw content to a file strictly within the current working directory (CWD). Paths must be relative (no leading /, no ..). Content written as-is (no escaping). **AUTO-VALIDATES JS FILES** with `node --check`; chmod +x shebangs. Retries syntax errors force LLM fix.
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Validation Logic
|
|
24
|
-
```javascript
|
|
25
|
-
// After fs.writeFile(resolvedPath, content, 'utf8');
|
|
26
|
-
const ext = path.extname(file).toLowerCase();
|
|
27
|
-
const isJS = ext === '.js' || content.startsWith('#!/usr/bin/env node');
|
|
28
|
-
const hasShebang = content.startsWith('#!');
|
|
29
|
-
|
|
30
|
-
if (isJS) {
|
|
31
|
-
try {
|
|
32
|
-
await SH`node --check ${[resolvedPath]}`.run();
|
|
33
|
-
validationMsg = ' ✓ JS syntax OK';
|
|
34
|
-
} catch (e) {
|
|
35
|
-
const errPreview = content.slice(0, 1000).split('\\n').slice(0, 20).join('\\n');
|
|
36
|
-
throw new Error(`❌ JS SYNTAX ERROR in '${file}' (node --check failed):
|
|
37
|
-
${e.message}
|
|
38
|
-
|
|
39
|
-
PREVIEW:
|
|
40
|
-
${errPreview}
|
|
41
|
-
|
|
42
|
-
... Fix escaping/backticks in template literals (use \\\\` for \` in JS strings) and retry.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (hasShebang) {
|
|
46
|
-
await SH`chmod +x ${[resolvedPath]}`.run();
|
|
47
|
-
validationMsg += ' ✓ chmod +x';
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Escaping Issues Resolved
|
|
52
|
-
- **Backticks in JS Strings**: Common LLM error—generates `` `hi` `` inside strings without escaping. Hint: `use \\\\` for \` in JS strings`.
|
|
53
|
-
- **Template Literals**: Ensures `` \` ${var} \` `` is valid; catches mismatched quotes.
|
|
54
|
-
- **Raw Content**: Verbatim write (newlines, `$|<> & " '\\`` preserved), but syntax-enforced.
|
|
55
|
-
- **No False Positives**: Only triggers on `.js` ext or Node shebang; preview limits noise.
|
|
56
|
-
|
|
57
|
-
**Example Error (LLM Sees)**:
|
|
58
|
-
```
|
|
59
|
-
❌ JS SYNTAX ERROR in 'test.js' (node --check failed):
|
|
60
|
-
SyntaxError: Unexpected token `
|
|
61
|
-
|
|
62
|
-
PREVIEW:
|
|
63
|
-
const msg = `Hello ${name}
|
|
64
|
-
...
|
|
65
|
-
|
|
66
|
-
... Fix escaping/backticks in template literals (use \\\\` for \` in JS strings) and retry.
|
|
67
|
-
```
|
|
68
|
-
- **LLM Fix**: Rewrites with `"Hello \${name}"` or proper `` \` `` nesting.
|
|
69
|
-
|
|
70
|
-
### Usage in Agents
|
|
71
|
-
```javascript
|
|
72
|
-
agent.addGenericToolcall('write_file'); // Auto-includes validation
|
|
73
|
-
await agent.directCall("Write test.js: const x = `hi`; console.log(x);"); // Passes
|
|
74
|
-
// Fails + retries: "Write test.js: const x = `hi; console.log(x);" → SyntaxError → Fix
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Multi-Language Syntax Validation (utils/syntax_check.sh)
|
|
78
|
-
|
|
79
|
-
**New Utility**: `./utils/syntax_check.sh` – Standalone script for **JS, Python, Bash, JSON**. Detects lang via ext/shebang, runs native checkers. Exit 0=OK, 1=error. Integrates as future `write_file` extension or new tool.
|
|
80
|
-
|
|
81
|
-
### Features
|
|
82
|
-
| Lang | Checker | Optional | Notes |
|
|
83
|
-
|------|---------|----------|-------|
|
|
84
|
-
| **JS** | `node --check` | - | Syntax only (no runtime). |
|
|
85
|
-
| **Python** | `python3 -m py_compile` | - | Bytecode compile. |
|
|
86
|
-
| **Bash/Sh** | `bash -n` + `shellcheck` | Shellcheck | Static + linter. |
|
|
87
|
-
| **JSON** | `node -e JSON.parse(...)` | - | Parse validation. |
|
|
88
|
-
| **Unknown** | Skip | - | Non-fatal. |
|
|
89
|
-
|
|
90
|
-
### Usage
|
|
91
|
-
```bash
|
|
92
|
-
./utils/syntax_check.sh path/to/file.js # 🔍 JS OK / ❌ error
|
|
93
|
-
./utils/syntax_check.sh script.py --verbose # Extra output
|
|
94
|
-
# Future: --fix (auto-retry via agent?)
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Script Source (utils/syntax_check.sh)
|
|
98
|
-
```bash
|
|
99
|
-
#!/bin/bash
|
|
100
|
-
set -euo pipefail
|
|
101
|
-
# Full script: Detects lang, validates, echoes status.
|
|
102
|
-
# Created: March 27, 2026
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Integration Proposal: New Tool `syntax_check`
|
|
106
|
-
Add to `ToolSet` / `genericToolset.js`:
|
|
107
|
-
```javascript
|
|
108
|
-
tools.add('syntax_check', 'Validate file syntax (JS/Py/Bash/JSON).', {
|
|
109
|
-
type: 'object',
|
|
110
|
-
properties: { file: {type: 'string'} },
|
|
111
|
-
required: ['file']
|
|
112
|
-
}, async ({file}) => {
|
|
113
|
-
const script = path.resolve(__dirname, '..', 'utils', 'syntax_check.sh');
|
|
114
|
-
return await SH`${script} "${file}"`.run();
|
|
115
|
-
});
|
|
116
|
-
```
|
|
117
|
-
- **Post-write Call**: `write_file` → `syntax_check` → LLM fix loop.
|
|
118
|
-
- **Extend write_file**: Run `./syntax_check.sh "$file"` after JS check.
|
|
119
|
-
|
|
120
|
-
**Cross-Links**:
|
|
121
|
-
- [ToolSet](../toolset.md#generic-tools)
|
|
122
|
-
- [AgentManager](../agent-manager.md#custom-tools--generics)
|
|
123
|
-
- Source: [lib/genericToolset.js](../lib/genericToolset.js)
|
|
124
|
-
|
|
125
|
-
**Updated**: March 27, 2026
|