diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index 9272cf23..6a53691e 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -51,8 +51,8 @@ jobs:
with:
go-version: '^1.22.0'
- - name: Install Grit
- run: npm install -g @getgrit/cli
+ - name: Install @getgrit/launcher
+ run: npm install -g @getgrit/launcher
- name: Run doctor
run: grit doctor
@@ -74,7 +74,7 @@ jobs:
- name: Run grit patterns test
run: |
if [ -n "${{ secrets.API_CLIENT_ID }}" ] && [ -n "${{ secrets.API_CLIENT_SECRET }}" ]; then
- grit patterns test --exclude flaky
+ grit patterns test --exclude ai
else
grit patterns test --exclude ai
fi
diff --git a/.grit/patterns/js/marzano.grit b/.grit/patterns/js/marzano.grit
index d63eec29..0c03a449 100644
--- a/.grit/patterns/js/marzano.grit
+++ b/.grit/patterns/js/marzano.grit
@@ -28,10 +28,7 @@ private pattern before_each_file_stdlib() {
}
private pattern after_each_file_stdlib() {
- and {
- after_each_file_handle_imports(),
- after_each_file_global_rewrites()
- }
+ after_each_file_handle_imports()
}
diff --git a/.grit/patterns/js/no_commented_out_code.md b/.grit/patterns/js/no_commented_out_code.md
index e5bbf4af..0b68f4bf 100644
--- a/.grit/patterns/js/no_commented_out_code.md
+++ b/.grit/patterns/js/no_commented_out_code.md
@@ -1,11 +1,12 @@
---
-tags: [hidden, linting, best-practice, recommended, ai, flaky]
+tags: [hidden, linting, best-practice, recommended, ai]
---
# No Commented Out Code
Please [don't commit commented out code](https://kentcdodds.com/blog/please-dont-commit-commented-out-code).
+
```grit
engine marzano(0.1)
language js
diff --git a/.grit/patterns/universal/ai/_ai_is_bare.md b/.grit/patterns/universal/ai/_ai_is_bare.md
index cf743dce..8fa26efc 100644
--- a/.grit/patterns/universal/ai/_ai_is_bare.md
+++ b/.grit/patterns/universal/ai/_ai_is_bare.md
@@ -1,11 +1,12 @@
---
-tags: [ai, sample, util, hidden, flaky]
+tags: [ai, sample, util, hidden]
---
# AI conditions.
Test `ai_is` with no counter-examples.
+
```grit
`console.log($msg)` => `// REDACTED: $msg` where {
$msg <: ai_is("references personally identifiable information")
diff --git a/.grit/patterns/universal/ai/_ai_match.md b/.grit/patterns/universal/ai/_ai_match.md
index c7278653..fe994f98 100644
--- a/.grit/patterns/universal/ai/_ai_match.md
+++ b/.grit/patterns/universal/ai/_ai_match.md
@@ -1,11 +1,12 @@
---
-tags: [ai, sample, util, hidden, flaky]
+tags: [ai, sample, util, hidden]
---
# AI conditions.
GritQL can use an AI for fuzzy matching. Just match the node you wish to analyze against the `ai_is` pattern.
+
```grit
`console.log($msg)` => `// REDACTED: $msg` where {
$msg <: ai_is("it references personally identifiable information")
diff --git a/.grit/patterns/universal/ai/_ai_rewrite.md b/.grit/patterns/universal/ai/_ai_rewrite.md
deleted file mode 100644
index 4eefafb6..00000000
--- a/.grit/patterns/universal/ai/_ai_rewrite.md
+++ /dev/null
@@ -1,263 +0,0 @@
----
-tags: [ai, sample, util, hidden, example]
----
-
-# AI rewrites
-
-Use `ai_rewrite($match, $instruct)` to rewrite a target variable based on some instruction.
-Edits might be made to other parts of the file if necessary to fulfill the intent of your instruction.
-
-```grit
-language yaml
-
-pattern pair($key, $value) {
- block_mapping_pair(key=contains $key, $value)
-}
-
-or {
- `- $task` where {
- $task <: block_mapping(items=some pair(key=`across`)),
- $task => ai_rewrite(match=$task, instruct="Replace this `across` task with `in_parallel` tasks, distributing the values across each child like this:
-
-Note that each replacement task will have the same name as the original task, but with `-1`, `-2`, etc. appended to it.
-
-in_parallel:
- - task: task-1
- - task: task-2
-")
- }
-}
-```
-
-## Handles a basic transform - currently
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - across:
- - var: name
- values:
- - file1
- - file2
- - file3
- task: create-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/((.:name))
- outputs:
- - name: manifests
- file: input.yaml
- - task: list-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- inputs:
- - name: manifests
- run:
- path: ls
- args:
- - manifests
-```
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - in_parallel:
- - task: create-file-1
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file1
- outputs:
- - name: manifests
- file: input.yaml
- - task: create-file-2
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file2
- outputs:
- - name: manifests
- file: input.yaml
- - task: create-file-3
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file3
- outputs:
- - name: manifests
- file: input.yaml
- - task: list-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- inputs:
- - name: manifests
- run:
- path: ls
- args:
- - manifests
-```
-
-## Handles a basic transform with two tasks
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - across:
- - var: name
- values:
- - file1
- - file2
- - file3
- task: create-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/((.:name))
- outputs:
- - name: manifests
- file: input.yaml
- - name: deploy-stuff
- plan:
- - across:
- - var: region
- values:
- - us-east-1
- - us-east-2
- - us-west-3
- task: deploy-code
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/((.:region))
- outputs:
- - name: manifests
- file: input.yaml
-```
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - in_parallel:
- - task: create-file-1
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file1
- outputs:
- - name: manifests
- file: input.yaml
- - task: create-file-2
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file2
- outputs:
- - name: manifests
- file: input.yaml
- - task: create-file-3
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file3
- outputs:
- - name: manifests
- file: input.yaml
- - name: deploy-stuff
- plan:
- - in_parallel:
- - task: deploy-code-1
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-east-1
- outputs:
- - name: manifests
- file: input.yaml
- - task: deploy-code-2
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-east-2
- outputs:
- - name: manifests
- file: input.yaml
- - task: deploy-code-3
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-west-3
- outputs:
- - name: manifests
- file: input.yaml
-```
diff --git a/.grit/patterns/universal/ai/_ai_transform.md b/.grit/patterns/universal/ai/_ai_transform.md
index 334b69ce..3fa4099d 100644
--- a/.grit/patterns/universal/ai/_ai_transform.md
+++ b/.grit/patterns/universal/ai/_ai_transform.md
@@ -1,11 +1,12 @@
---
-tags: [ai, sample, util, hidden, example, flaky]
+tags: [ai, sample, util, hidden, example]
---
# AI transform
GritQL can use AI to transform a target variable based on some instruction using the `ai_transform` function.
+
```grit
language yaml
@@ -91,116 +92,9 @@ jobs:
path: touch
args:
- manifests/file2
- outputs:
- - name: manifestsd
- file: input.yaml
- - task: task-3
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file3
outputs:
- name: manifests
file: input.yaml
-
- - task: list-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- inputs:
- - name: manifests
- run:
- path: ls
- args:
- - manifests
-```
-
-## Handles a basic transform with two tasks
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - across:
- - var: name
- values:
- - file1
- - file2
- - file3
- task: create-file
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/((.:name))
- outputs:
- - name: manifests
- file: input.yaml
- - name: deploy-stuff
- plan:
- - across:
- - var: region
- values:
- - us-east-1
- - us-east-2
- - us-west-3
- task: deploy-code
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/((.:region))
- outputs:
- - name: manifests
- file: input.yaml
-```
-
-```yaml
-jobs:
- - name: build-and-use-image
- plan:
- - in_parallel:
- - task: task-1
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file1
- outputs:
- - name: manifests
- file: input.yaml
- - task: task-2
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: touch
- args:
- - manifests/file2
- outputs:
- - name: manifestsd
- file: input.yaml
- task: task-3
config:
platform: linux
@@ -214,7 +108,7 @@ jobs:
outputs:
- name: manifests
file: input.yaml
-
+
- task: list-file
config:
platform: linux
@@ -227,37 +121,4 @@ jobs:
path: ls
args:
- manifests
- - name: deploy-stuff
- plan:
- - in_parallel:
- - task: deploy-code
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-east-1
- - task: deploy-code
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-east-2
- - task: deploy-code
- config:
- platform: linux
- image_resource:
- type: registry-image
- source: { repository: busybox }
- run:
- path: deploy
- args:
- - aws/us-west-3
```
diff --git a/.grit/patterns/universal/ai/_ai_transform_simple.md b/.grit/patterns/universal/ai/_ai_transform_simple.md
deleted file mode 100644
index 91d6917a..00000000
--- a/.grit/patterns/universal/ai/_ai_transform_simple.md
+++ /dev/null
@@ -1,93 +0,0 @@
----
-tags: [ai, sample, util, hidden, example]
----
-
-This is a simple test transformation to convert arrow functions to traditional functions
-
-```grit
-language js
-
-`($_) => $_` as $arrow where {
- $arrow <: not contains `callOutside($_)`,
-} => ai_rewrite($arrow, instruct="Convert all arrow function to traditional function syntax using `function`")
-```
-
-## Simple test case
-
-```js
-// This is my file
-const MY_VAR = 9;
-
-// This is my arrow function
-const myArrow = (a, b) => a + b;
-
-// This is my second arrow function
-const myArrow2 = (foo: string) => {
- console.log('Checking foo', foo);
- return foo.length;
-};
-```
-
-```js
-// This is my file
-const MY_VAR = 9;
-
-// This is my arrow function
-const myArrow = function (a, b) {
- return a + b;
-};
-
-// This is my second arrow function
-const myArrow2 = function (foo: string) {
- console.log('Checking foo', foo);
- return foo.length;
-};
-```
-
-## Harder case
-
-This case has some arrow functions that should _NOT_ be modified.
-
-```js
-// This is my file
-const MY_VAR = 9;
-
-// This is someone else's arrow function
-const theirArrow = (a, b) => {
- console.log('HELLO SIR');
- callOutside('world');
- return a % b;
-};
-
-// This is my arrow function
-const myArrow = (a, b) => a + b;
-
-// This is my second arrow function
-const myArrow2 = (foo: string) => {
- console.log('Checking foo', foo);
- return foo.length;
-};
-```
-
-```js
-// This is my file
-const MY_VAR = 9;
-
-// This is someone else's arrow function
-const theirArrow = (a, b) => {
- console.log('HELLO SIR');
- callOutside('world');
- return a % b;
-};
-
-// This is my arrow function
-const myArrow = function (a, b) {
- return a + b;
-};
-
-// This is my second arrow function
-const myArrow2 = function (foo: string) {
- console.log('Checking foo', foo);
- return foo.length;
-};
-```
diff --git a/.grit/patterns/universal/ai/ai.grit b/.grit/patterns/universal/ai/ai.grit
index d41cc736..f4008877 100644
--- a/.grit/patterns/universal/ai/ai.grit
+++ b/.grit/patterns/universal/ai/ai.grit
@@ -107,8 +107,6 @@ $match
}
],
- log($messages),
-
$answer = llm_chat($messages, $pattern, model="claude-3-haiku-20240307", stop_sequences=[""]),
$answer <: includes r"(?:\s+)([\s\S]+)"($final),
diff --git a/.grit/patterns/universal/ai/ai_choose_example.md b/.grit/patterns/universal/ai/ai_choose_example.md
index d9aedd71..87c2427d 100644
--- a/.grit/patterns/universal/ai/ai_choose_example.md
+++ b/.grit/patterns/universal/ai/ai_choose_example.md
@@ -1,5 +1,5 @@
---
-tags: [ai, sample, util, hidden, flaky]
+tags: [ai, sample, util, hidden]
---
# Ask an AI
@@ -8,6 +8,7 @@ GritQL includes built-in support for querying an AI to answer questions in patte
For example, you can use the `ai_choose` function to choose a name for a function.
+
```grit
language js
diff --git a/.grit/patterns/universal/ai/ai_rewrite.grit b/.grit/patterns/universal/ai/ai_rewrite.grit
deleted file mode 100644
index 3d6d3cda..00000000
--- a/.grit/patterns/universal/ai/ai_rewrite.grit
+++ /dev/null
@@ -1,57 +0,0 @@
-language universal
-
-// Transform the provided code to match the given instructions
-function ai_rewrite($match, $instruct) {
- if ($GLOBAL_REWRITE_INSTRUCTION <: not or { $instruct, $undefined }) {
- $match => `"Only a single ai_rewrite can be used per pattern."`
- } else {
- $GLOBAL_REWRITE_INSTRUCTION = $instruct,
- return `$match`
- }
-}
-
-pattern after_each_file_global_rewrites() {
- if ($GLOBAL_REWRITE_INSTRUCTION <: not undefined) {
- file($body) where {
- $code_with_markers = text($body, true),
- $instruct = $GLOBAL_REWRITE_INSTRUCTION,
- $messages = [
- {
- role: "system",
- content: raw`Your job is to help rewrite code based on user instructions.
-
- You will be given a file which has been annotated with specific ranges to modify.
-
- The target ranges will be marked with tags.
-
- Given the instructions, you should return a full copy of the file with the appropriate modifications applied based on the user instructions.
-
- The file should be surrounded by tags. You should include the full, modified file, in your response.
- `
- },
- {
- role: "user",
- content: `
- $instruct
-
-
- $code_with_markers
- `
- },
- {
- role: "assistant",
- content: `Here is the file, with modifications made per your instructions.
-
- `
- }
- ],
-
- $answer = llm_chat($messages, $pattern, model="claude-3-5-sonnet-20240620", stop_sequences=[""]),
- // log($answer)
- $answer <: includes r"(?:\s+)([\s\S]+)"($final),
- $body => $final
- }
- }
-}
-
-
diff --git a/.grit/patterns/yaml/marzano.grit b/.grit/patterns/yaml/marzano.grit
deleted file mode 100644
index 17bafc5a..00000000
--- a/.grit/patterns/yaml/marzano.grit
+++ /dev/null
@@ -1,19 +0,0 @@
-language yaml
-
-// All core stdlib functions can be done here
-private pattern before_each_file_stdlib() {
- file()
-}
-
-private pattern after_each_file_stdlib() {
- after_each_file_global_rewrites()
-}
-
-// These could be redefined in the future (not presently supported)
-pattern before_each_file() {
- before_each_file_stdlib()
-}
-
-pattern after_each_file() {
- after_each_file_stdlib()
-}