https://github.com/firstbatchxyz/dria-cli
A command-line tool to interact with Dria knowledge.
https://github.com/firstbatchxyz/dria-cli
Last synced: about 1 year ago
JSON representation
A command-line tool to interact with Dria knowledge.
- Host: GitHub
- URL: https://github.com/firstbatchxyz/dria-cli
- Owner: firstbatchxyz
- License: apache-2.0
- Created: 2024-02-06T07:00:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-03T19:48:28.000Z (over 2 years ago)
- Last Synced: 2025-05-03T17:44:02.693Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://dria.co/
- Size: 130 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Dria CLI
Dria CLI is a command-line tool that can be used to interact with Dria locally.
## Installation
Dria CLI requires NodeJS (>= 18.0.0) & Docker to be installed on your machine, and is available on NPM. It can be installed to your system with:
```sh
npm i -g dria-cli
```
## Usage
You can see available commands with `dria help`, which outputs:
```sh
dria
Commands:
dria pull [contract] Pull a knowledge to your local machine.
dria serve [contract] Serve a local knowledge.
dria clear [contract] Clear local knowledge.
dria fetch Fetch an existing index on Arweave.
dria extract Extract a compressed knowledge.
dria set-contract Set default contract.
dria config Show default configurations.
dria list List all local knowledge.
dria stop Stop serving knowledge.
Options:
--help Show help [boolean]
--version Show version number [boolean]
-v, --verbose Show extra information [boolean] [default: false]
```
> [!WARNING]
>
> If you are using Docker with `sudo` only, you must use the Dria CLI with `sudo` as well, since it needs access
> to Docker in the background. Otherwise, the CLI will not be able to detect your Docker engine.
> See more [here](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user).
### Pull Knowledge
A Dria knowledge is stored on blockchain, and we can pull that knowledge to our local machine with the `pull` command:
```sh
dria pull
dria pull # use configured contract
```
### Serve Knowledge
After [pulling](#pull-knowledge) a knowledge, you can serve the HNSW index over it with:
```sh
dria serve
dria serve # use configured contract
```
### Stop Serving
The [served](#serve-knowledge) HNSW index runs in the background, and you can stop it anytime with:
```sh
dria stop
```
### Fetch Knowledge
You can download an existing HNSW index that lives in RocksDB and is zipped & uploaded to Arweave, which is much a faster option than `dria pull` command for an existing index.
```sh
dria fetch
```
Note that the argument here is not the knowledge ID (i.e. the corresponding Arweave contract txID); instead, it is the transaction ID of the bundling transaction where the RocksDB folder was zipped & uploaded to Arweave.
### Extract Knowledge
The previously mentioned [fetch](#fetch-knowledge) command downloads a zip file from Arweave & extracts it. However, in some cases you might have the knowledge on another platform that is easier to access compared to downloading from Arweave, especially if internet connection is an issue. For such cases, we have the extract command which simply unzips the compressed knowledge under Dria's data directory.
```sh
dria extract
```
### Configurations
You can set the default contract with `set-contract` command. When a contract is set by default, `[contract]` can be omitted such that the CLI will use the default one. To see the defaults:
```sh
# view configurations
dria config
# change contract
dria set-contract
```
### List Knowledge
You can print out the list of contracts [pulled](#pull-knowledge) or [fetched](#fetch-knowledge) so far, along with their last modification date, with the command:
```sh
dria list
```
> [!NOTE]
>
> If a knowledge has new data inserted to it, you will have to pull it again to catch up.
### Remove Knowledge
To clear up some space by deleting a knowledge, use:
```sh
dria clear
dria clear # use configured contract
```
## Setup
To setup the repository locally, first you must clone it:
```sh
git clone https://github.com/firstbatchxyz/dria-cli.git
cd dria-cli
```
Then, install packages with:
```sh
yarn install
```
You can run the CLI as if you are calling `npx dria` with the following command:
```sh
yarn dria
```
## Styling
You can lint & check formatting with:
```sh
yarn lint
yarn format
```
## License
See [LICENSE](./LICENSE).