Skip to content

Commit a98f0f5

Browse files
committed
docs: update installation instructions and initialization code for plugins
1 parent ce9e45d commit a98f0f5

4 files changed

Lines changed: 87 additions & 25 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: AST Grep
3+
description: Use the ast-grep plugin to parse and manipulate code
4+
sidebar:
5+
order: 80
6+
---
7+
8+
import { PackageManagers } from "starlight-package-managers";
9+
10+
These runtime helpers provide a friendly wrapper around the [ast-grep](https://ast-grep.github.io/).
11+
12+
## Installation
13+
14+
<PackageManagers pkg="@genaiscript/plugin-ast-grep" dev />
15+
16+
If you are using the plugin in a Node.JS environment, without a `.genai...` entry file, you will need
17+
to initialize the [runtime](/genaiscript/reference/runtime) before using the plugin:
18+
19+
```ts
20+
import { initialize } from "@genaiscript/runtime";
21+
22+
await initialize();
23+
```
24+
25+
## Usage
26+
27+
See the [ast-grep](/genaiscript/reference/scripts/ast-grep) script for examples of how to use the plugin.

docs/src/content/docs/reference/runtime/plugin-mdast.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@ import { PackageManagers } from "starlight-package-managers";
1010
These runtime helpers provide a friendly wrapper around the [remark](https://github.com/remarkjs/remark), [mdast](https://github.com/syntax-tree/mdast), [unified](https://github.com/syntax-tree/unist)
1111
ecosystem to parse and manipulate Markdown documents.
1212

13-
In order to get type completion, you will need to install the `@types/mdast` package as a development dependency.
13+
## Installation
14+
15+
<PackageManagers pkg="@genaiscript/plugin-mdast" dev />
1416

15-
<PackageManagers pkg="@types/mdast" dev />
17+
If you are using the plugin in a Node.JS environment, without a `.genai...` entry file, you will need
18+
to initialize the [runtime](/genaiscript/reference/runtime) before using the plugin:
19+
20+
```ts
21+
import { initialize } from "@genaiscript/runtime";
22+
23+
await initialize()
24+
```
1625

1726
## Markdown manipulation
1827

1928
- load the parsers
2029

2130
```typescript
22-
import { mdast } from "@genaiscript/runtime";
31+
import { mdast } from "@genaiscript/plugin-mdast";
2332

2433
const { parse, visit, stringify } = await mdast();
2534
```
@@ -43,3 +52,5 @@ const updated = visit(root, `code`, (node) => {
4352
```typescript
4453
const markdown = await stringify(updated);
4554
```
55+
56+
In order to get type completion, you will need to install the `@types/mdast` package as a development dependency.

docs/src/content/docs/reference/runtime/plugin-mermaid.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: plugin-mermaid
2+
title: MermaidJs
33
description: Use the mermaid plugin to parse mermaid diagrams
44
---
55

@@ -13,6 +13,16 @@ The [@genaiscript/plugin-mermaid](https://www.npmjs.com/package/@genaiscript/plu
1313

1414
<PackageManagers pkg="@genaiscript/plugin-mermaid" dev />
1515

16+
If you are using the plugin in a Node.JS environment, without a `.genai...` entry file, you will need
17+
to initialize the [runtime](/genaiscript/reference/runtime) before using the plugin:
18+
19+
```ts
20+
import { initialize } from "@genaiscript/runtime";
21+
22+
await initialize()
23+
```
24+
25+
1626
## Usage
1727

1828
```ts

docs/src/content/docs/reference/runtime/plugin-z3.mdx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
11
---
22
title: Z3
3-
description: Z3 is a high-performance theorem prover developed at Microsoft
4-
Research. It is a built-in tool of GenAIScript.
3+
description:
4+
Z3 is a high-performance theorem prover developed at Microsoft
5+
Research. It is a built-in tool of GenAIScript.
56
sidebar:
6-
order: 200
7+
order: 200
78
hero:
8-
image:
9-
alt:
10-
"A small, 8-bit style computer chip labeled as Z3 is centrally positioned,
11-
with fine lines linking it to three simple shapes: a circle containing a
12-
checkmark to suggest problem solving, a square featuring an inequality
13-
sign to indicate logical constraints, and a triangle with tiny gears
14-
inside to represent verifying programs. The image uses only blue, gray,
15-
black, white, and green, appears flat and geometric with a professional,
16-
minimalistic look, and has no background or human figures."
17-
file: ./plugin-z3.png
9+
image:
10+
alt:
11+
"A small, 8-bit style computer chip labeled as Z3 is centrally positioned,
12+
with fine lines linking it to three simple shapes: a circle containing a
13+
checkmark to suggest problem solving, a square featuring an inequality
14+
sign to indicate logical constraints, and a triangle with tiny gears
15+
inside to represent verifying programs. The image uses only blue, gray,
16+
black, white, and green, appears flat and geometric with a professional,
17+
minimalistic look, and has no background or human figures."
18+
file: ./plugin-z3.png
1819
---
1920

2021
[Z3](https://microsoft.github.io/z3guide/) is a high-performance theorem prover developed at Microsoft Research. It is a built-in tool of GenAIScript. Z3 is used to solve logical formulas
2122
and can be used for various applications, including program verification, constraint solving, and symbolic execution.
2223

2324
GenAIScript uses the WebAssembly-based [z3-solver](https://www.npmjs.com/package/z3-solver) npm package to run Z3.
2425

26+
## Installation
27+
28+
<PackageManagers pkg="@genaiscript/plugin-z3" dev />
29+
30+
If you are using the plugin in a Node.JS environment, without a `.genai...` entry file, you will need
31+
to initialize the [runtime](/genaiscript/reference/runtime) before using the plugin:
32+
33+
```ts
34+
import { initialize } from "@genaiscript/runtime";
35+
36+
await initialize();
37+
```
38+
2539
## Z3 instance
2640

27-
The `host.z3()` method creates a new Z3 instance. The instance can be used to run Z3 commands and get the results.
41+
The `z3()` method creates a new Z3 instance. The instance can be used to run Z3 commands and get the results.
2842
The `z3` instance is a wrapper around the [z3-solver](https://www.npmjs.com/package/z3-solver) npm package.
2943
The `z3` instance has the `run` method that runs the given SMTLIB2 formula and returns the result.
3044

3145
```js
32-
import { z3 } from "@genaiscript/plugin-z3"
46+
import { z3 } from "@genaiscript/plugin-z3";
3347

34-
const z3 = await z3()
48+
const z3 = await z3();
3549
const res = await z3.run(`
3650
(declare-const a Int)
3751
(declare-fun f (Int Bool) Int)
3852
(assert (< a 10))
3953
(assert (< (f a true) 100))
4054
(check-sat)
41-
`)
42-
console.log(res) // unsat
55+
`);
56+
console.log(res); // unsat
4357
```
4458

4559
## Z3 tool
@@ -70,16 +84,16 @@ tool with a LLM that can (try to) formalize arbitrary problems to SMTLIB2.
7084
7185
```js
7286
script({
73-
tools: ["agent_z3"],
74-
})
87+
tools: ["agent_z3"],
88+
});
7589
7690
$`Solve the following problems using Z3:
7791
7892
Imagine we have a number called 'a' that is smaller than 10.
7993
We also have a special machine called 'f' that takes a number and a 'true'/'false' answer,
8094
and it gives back another number.
8195
When we put the number 'a' and the answer “true” into this machine,
82-
the number it gives us is smaller than 100.`
96+
the number it gives us is smaller than 100.`;
8397
```
8498
8599
:::note

0 commit comments

Comments
 (0)