AI prompts
base on Interactive grep (for streaming) # sig
[![ci](https://github.com/ynqa/sig/actions/workflows/ci.yml/badge.svg)](https://github.com/ynqa/sig/actions/workflows/ci.yml)
Interactive grep
|![sig.gif](https://github.com/ynqa/ynqa/blob/master/demo/sig.gif)|![sig_archived.gif](https://github.com/ynqa/ynqa/blob/master/demo/sig_archived.gif)|
|---|---|
## Features
- Interactive grep (for streaming)
- *sig* allows users to interactively search through (streaming) data,
updating results in real-time.
- Re-execute command
- If `--cmd` is specified instread of piping data to *sig*,
the command will be executed on initial and retries.
- This feature is designed to address the issue where data streams
past while the user is fine-tuning the search criteria.
In other words, even if the data has already passed,
executing the command again allows
the retrieval of the data for re-evaluation.
- Archived mode
- In archived mode, since there is no seeking capability
for streaming data received through a pipe,
it is not possible to search backwards without exiting the process.
Therefore, in *sig*, the latest N entries of streaming data are saved,
and it is possible to switch to a mode
where you can grep through these N entries
based on key inputs at any given moment.
- Additionally, by starting in this mode,
it is also possible to grep through static data such as files.
- like [ugrep](https://github.com/Genivia/ugrep) with `-Q` option.
## Installation
### Homebrew
```bash
brew install ynqa/tap/sigrs
```
### Cargo
```bash
cargo install sigrs
```
### Arch Linux
```bash
pacman -S sig
```
### Nix (flakes)
Add it as an input to your flake:
```nix
inputs = {
sig.url = 'github:ynqa/sig/<optional-ref>'
}
```
Create a shell with it:
```nix
nix shell github:ynqa/sig
```
Or run it directly:
```nix
cat README.md | nix run github:ynqa/sig -- --archived
```
### Nix (classic)
Fetch the source and use it, e.g. in your shell:
```nix
let
# At the time of writing this, pkgs need to be unstable for the package to build properly
# (requires Rust 1.74, stable has 1.73)
pkgs = import <nixpkgs-unstable> {};
sig = pkgs.callPackage (pkgs.fetchFromGitHub {
owner = "ynqa";
repo = "sig";
rev = "<revision, e.g. master/v0.1.0/etc.>";
hash = ""; # Build first, put proper hash in place
}) {};
in
pkgs.mkShell {
packages = [sig];
}
```
## Examples
```bash
stern --context kind-kind etcd |& sig
# or
sig --cmd "stern --context kind-kind etcd" # this is able to retry command by ctrl+r.
```
### Archived mode
```bash
cat README.md |& sig -a
# or
sig -a --cmd "cat README.md"
```
## Keymap
| Key | Action
| :- | :-
| <kbd>Ctrl + C</kbd> | Exit `sig`
| <kbd>Ctrl + R</kbd> | Retry command if `--cmd` is specified
| <kbd>Ctrl + F</kbd> | Enter Archived mode
| <kbd>←</kbd> | Move the cursor one character to the left
| <kbd>→</kbd> | Move the cursor one character to the right
| <kbd>Ctrl + A</kbd> | Move the cursor to the start of the filter
| <kbd>Ctrl + E</kbd> | Move the cursor to the end of the filter
| <kbd>Backspace</kbd> | Delete a character of filter at the cursor position
| <kbd>Ctrl + U</kbd> | Delete all characters of filter
(Archived mode)
| Key | Action
| :- | :-
| <kbd>Ctrl + C</kbd> | Exit Archived mode
| <kbd>←</kbd> | Move the cursor one character to the left
| <kbd>→</kbd> | Move the cursor one character to the right
| <kbd>Ctrl + A</kbd> | Move the cursor to the start of the filter
| <kbd>Ctrl + E</kbd> | Move the cursor to the end of the filter
| <kbd>Backspace</kbd> | Delete a character of filter at the cursor position
| <kbd>Ctrl + U</kbd> | Delete all characters of filter
## Usage
```bash
Interactive grep (for streaming)
Usage: sig [OPTIONS]
Examples:
$ stern --context kind-kind etcd |& sig
Or the method to retry command by pressing ctrl+r:
$ sig --cmd "stern --context kind-kind etcd"
Archived mode:
$ cat README.md |& sig -a
Or
$ sig -a --cmd "cat README.md"
Options:
--retrieval-timeout <RETRIEVAL_TIMEOUT_MILLIS>
Timeout to read a next line from the stream in milliseconds. [default: 10]
--render-interval <RENDER_INTERVAL_MILLIS>
Interval to render a line in milliseconds. [default: 10]
-q, --queue-capacity <QUEUE_CAPACITY>
Queue capacity to store lines. [default: 1000]
-a, --archived
Archived mode to grep through static data.
-i, --ignore-case
Case insensitive search.
--cmd <CMD>
Command to execute on initial and retries.
-h, --help
Print help (see more with '--help')
-V, --version
Print version
```
", Assign "at most 3 tags" to the expected json: {"id":"10434","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"