-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'convert' command for GenAIScript processing (#953)
* feat: add 'convert' command for GenAIScript processing ♻️ * feat: ➿ Add support for concurrent file conversions * ci: 🧪 add model version and error logging * feat: ✨ add rewrite and cancel-word options to CLI * docs: ✏️ add convert command documentation * fix: 🐛 refine file processing logic and instructions * refactor: update text assignment logic 💡 * refactor: ♻️ Remove unnecessary file fetching logic * feat: ✨ add --cancel-word option to CLI convert command * fix: handle cancelled files in conversion process 🛑
- Loading branch information
Showing
16 changed files
with
417 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
title: Convert | ||
description: Learn how to apply a script to many files and extract the output. | ||
sidebar: | ||
order: 2 | ||
keywords: CLI tool execution, genai script running, stdout streaming, file globing, environment configuration | ||
--- | ||
|
||
Converts a set of files, separately, using a script. | ||
|
||
```bash | ||
npx genaiscript convert <script> "<files...>" | ||
``` | ||
|
||
where `<script>` is the id or file path of the tool to run, and `<files...>` is the name of the spec file to run it on. | ||
Unlike `run` which works on all files at once, `convert` processes each file individually. | ||
|
||
## Files | ||
|
||
`convert` takes one or more [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns to match files in the workspace. | ||
|
||
```bash sh | ||
npx genaiscript run <script> "**/*.md" "**/*.ts" | ||
``` | ||
|
||
### --excluded-files <files...> | ||
|
||
Excludes the specified files from the file set. | ||
|
||
```sh "--excluded-files <excluded-files...>" | ||
npx genaiscript convert <script> <files> --excluded-files <excluded-files...> | ||
``` | ||
|
||
### --exclude-git-ignore | ||
|
||
Exclude files ignored by the `.gitignore` file at the workspace root. | ||
|
||
```sh "--exclude-git-ignore" | ||
npx genaiscript convert <script> <files> --exclude-git-ignore | ||
``` | ||
|
||
## Output | ||
|
||
The output of each file is saved to a new or existing file. You can control the logic to decide which part of the output to save where to save it. | ||
By default, a conversion result of a file `<filename>` is saved to a file `<filename>.genai.md`. | ||
|
||
### --suffix <suffix> | ||
|
||
The `--suffix` option allows you to specify a suffix to append to the output file name. | ||
|
||
```sh "--suffix .genai.txt" | ||
npx genaiscript convert <script> <files> --suffix .genai.txt | ||
``` | ||
|
||
GenAIScript will "unfence" output in the markdown that match the suffix (after `.genai`) automatically. So if the LLM generates | ||
|
||
````markdown | ||
```txt | ||
:) | ||
``` | ||
```` | ||
|
||
The converted content in `<filename>.genai.txt` will be `:)`. | ||
|
||
### --rewrite | ||
|
||
This flag override `suffix` and tells GenAIScript to rewrite the original file with the converted content. | ||
|
||
```sh "--rewrite" | ||
npx genaiscript convert <script> <files> --rewrite | ||
``` | ||
|
||
### --cancel-word <word> | ||
|
||
Specify the "ignore output, nothing to see here" keyword using the `-cw` flag. | ||
|
||
```sh '--cancel-word "<NO>"' | ||
npx genaiscript convert <script> <files> --cancel-word "<NO>" | ||
``` | ||
|
||
## Read more | ||
|
||
The full list of options is available in the [CLI reference](/genaiscript/reference/cli/commands#convert). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.