You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Use as a refactoring language / _diff_ format](#use-as-a-refactoring-language--_diff_-format)
22
+
-[Tool Use](#tool-use)
23
+
-[Run Python scripts to find the correct answer for certain types of problems](#run-python-scripts-to-find-the-correct-answer-for-certain-types-of-problems)
24
+
-[Obtain the current local weather](#obtaining-the-current-local-weather)
25
+
-[Get a list of image files in the current working dir](#get-a-list-of-image-files-in-the-current-working-dir)
26
+
-[Take a peek at the user's screen and right-click on the user's clock widget](#take-a-peek-at-the-users-screen-and-right-click-on-the-users-clock-widget)
17
27
-[Proposals](#proposals)
18
28
-[Related](#related)
19
29
20
30
## What is CEDARScript?
21
31
22
-
A SQL-like language for efficient code analysis and transformations.
23
-
24
-
Most useful for AI code assistants.
25
-
26
32
It's a domain-specific language designed to improve how AI coding assistants interact with codebases and communicate their code modification intentions.
33
+
27
34
It provides a standardized way to express complex code modification and analysis operations, making it easier for
28
35
AI-assisted development tools to understand and execute these tasks.
29
36
37
+
It also works as a gateway to external tools, so that the LLM can easily call local shell commands, external HTTP API endpoints, etc
38
+
30
39
## How to use it
31
40
32
41
1. You can easily [install a tool that supports CEDARScript](https://github.com/CEDARScript/cedarscript-integration-aider/blob/main/README.md#installation).
@@ -93,7 +102,7 @@ character- or line-level editing tasks.
93
102
The CEDARScript runtime then handles all the minute details - precise line numbers, indentation counts, and syntax
94
103
consistency - at zero token cost.
95
104
96
-
Let's get to know the two primary functions offered by CEDARScript:
105
+
Let's get to know the 3 primary functions offered by CEDARScript:
97
106
98
107
1.**Code Analysis** to quickly get to know a large code base without having to read all contents of all files.
99
108
- The CEDARScript runtime searches through the whole code base and only returns the relevant results,
@@ -111,6 +120,8 @@ so on, allowing the _CEDARScript commands_ to focus instead on higher levels of
[indentations](grammar.js#L306-L370) and [positions](grammar.js#L241-L300)
113
122
(`AFTER`, `BEFORE`, `INTO` a function, its `BODY`, at the `TOP` or `BOTTOM` of it...)
123
+
3.**[Tool Use](#tool-use)**: The runtime acts as a gateway through which the LLM can send and receive information.
124
+
This opens up many possibilities.
114
125
115
126
## Key Features:
116
127
@@ -167,18 +178,7 @@ This efficiency allows for more complex operations within token limits.
167
178
168
179
It provides a concise way to express complex code modification and analysis operations, making it easier for AI-assisted development tools to understand and perform these tasks.
169
180
170
-
### Use as a refactoring language / _diff_ format
171
-
172
-
One can use `CEDARScript` to concisely and unambiguously represent code modifications at a higher level than a standard diff format can.
173
-
174
-
IDEs can store the local history of files in CEDARScript format, and this can also be used for searches.
175
-
176
-
### Other Ideas to Explore
177
-
- Code review systems for automated, in-depth code assessments
178
-
- Automated code documentation and explanation tools
179
-
- ...
180
-
181
-
## Examples
181
+
#### Codebase Interaction Examples
182
182
183
183
Quick example: turn a method into a top-level function, using `CASE` filter with REGEX:
184
184
@@ -230,6 +230,123 @@ UPDATE FILE "app/main.py" REPLACE FUNCTION "calculate_total" WITH ED '''
230
230
231
231
There are [many more examples](test/corpus) to look at...
232
232
233
+
### Use as a refactoring language / _diff_ format
234
+
235
+
One can use `CEDARScript` to concisely and unambiguously represent code modifications at a higher level than a standard diff format can.
236
+
237
+
IDEs can store the local history of files in CEDARScript format, and this can also be used for searches.
238
+
239
+
### Tool Use
240
+
If **explicit** configuration is set, the [**CEDARScript runtime**](https://github.com/CEDARScript/cedarscript-editor-python) can act as
241
+
a gateway through which an LLM can:
242
+
1. Call local commands (`ls`, `grep`, `find`, `open`)
243
+
2. Run scripts
244
+
3. Call external HTTP API services
245
+
4. See the user's screen and take control of the mouse and keyboard
246
+
5. Possibilities are numerous...
247
+
248
+
The output from the external tool is captured and sent back to the LLM.
249
+
250
+
#### Tool Use Examples
251
+
252
+
#### Run Python scripts to find the correct answer for certain types of problems
253
+
254
+
```sql
255
+
-- Suppose the LLM has difficulty counting letters...
256
+
-- It can delegate the counting to a Python script:
257
+
CALL LANGUAGE "python" WITH CONTENT '''
258
+
print("Refrigerator".lower().count('r'))
259
+
''';
260
+
```
261
+
262
+
```sql
263
+
-- Using env var
264
+
CALL LANGUAGE "python"
265
+
ENV CONTENT '''WORD=Refrigerator'''
266
+
WITH CONTENT '''
267
+
import os
268
+
print(os.environ['WORD'].count('r'))
269
+
''';
270
+
```
271
+
272
+
```sql
273
+
-- Using env var from the host computer
274
+
CALL LANGUAGE "python"
275
+
ENV INHERIT ONLY 'WORD'
276
+
WITH CONTENT '''
277
+
import os
278
+
print(os.environ['WORD'].count('r'))
279
+
''';
280
+
```
281
+
282
+
#### Obtain the current local weather
283
+
284
+
```sql
285
+
CALL COMMAND
286
+
ENV INHERIT ONLY 'LOCATION'-- Get the current location from the host env var
0 commit comments