From 5fec3b967b0636941360a65caa16cfa92ac946e8 Mon Sep 17 00:00:00 2001 From: despiegk Date: Sat, 5 Apr 2025 07:23:00 +0200 Subject: [PATCH] ... --- docs/cfg/footer.json | 72 ------------------------ {docs => src/docs}/.gitignore | 0 src/docs/cfg/footer.json | 22 ++++++++ {docs => src/docs}/cfg/main.json | 16 +++--- {docs => src/docs}/cfg/navbar.json | 0 src/docs/docs/intro.md | 7 +++ src/docs/docs/sal/_category_.json | 8 +++ src/docs/{subdir => docs/sal}/buildah.md | 16 ++++-- src/docs/{subdir => docs/sal}/git.md | 38 +++++++------ src/docs/docs/sal/intro.md | 10 ++++ src/docs/{subdir => docs/sal}/os.md | 40 +++++++------ src/docs/{subdir => docs/sal}/process.md | 28 +++++---- src/docs/subdir/README.md | 30 ---------- src/docs/subdir/_category_.json | 8 --- src/docs/tech.md | 54 ------------------ 15 files changed, 128 insertions(+), 221 deletions(-) delete mode 100644 docs/cfg/footer.json rename {docs => src/docs}/.gitignore (100%) create mode 100644 src/docs/cfg/footer.json rename {docs => src/docs}/cfg/main.json (54%) rename {docs => src/docs}/cfg/navbar.json (100%) create mode 100644 src/docs/docs/intro.md create mode 100644 src/docs/docs/sal/_category_.json rename src/docs/{subdir => docs/sal}/buildah.md (96%) rename src/docs/{subdir => docs/sal}/git.md (94%) create mode 100644 src/docs/docs/sal/intro.md rename src/docs/{subdir => docs/sal}/os.md (96%) rename src/docs/{subdir => docs/sal}/process.md (97%) delete mode 100644 src/docs/subdir/README.md delete mode 100644 src/docs/subdir/_category_.json delete mode 100644 src/docs/tech.md diff --git a/docs/cfg/footer.json b/docs/cfg/footer.json deleted file mode 100644 index 0479bf9..0000000 --- a/docs/cfg/footer.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "style": "dark", - "links": [ - { - "title": "Docs", - "items": [ - { - "label": "Introduction", - "to": "/docs/introduction" - }, - { - "label": "Litepaper", - "to": "/docs/litepaper" - }, - { - "label": "Roadmap", - "to": "/docs/roadmap" - }, - { - "label": "Manual", - "href": "https://manual.grid.tf/" - } - ] - }, - { - "title": "Features", - "items": [ - { - "label": "Become a Farmer", - "to": "/docs/category/become-a-farmer" - }, - { - "label": "Components", - "to": "/docs/category/components" - }, - { - "label": "Tokenomics", - "to": "/docs/tokens/tokenomics" - }, - { - "label": "Technology", - "to": "/docs/tech" - } - ] - }, - { - "title": "Web", - "items": [ - { - "label": "ThreeFold.io", - "href": "https://threefold.io" - }, - { - "label": "Dashboard", - "href": "https://dashboard.grid.tf" - }, - { - "label": "GitHub", - "href": "https://github.com/threefoldtech/home" - }, - { - "href": "https://mycelium.threefold.io/", - "label": "Mycelium Network" - }, - { - "href": "https://aibox.threefold.io/", - "label": "AI Box" - } - ] - } - ] -} diff --git a/docs/.gitignore b/src/docs/.gitignore similarity index 100% rename from docs/.gitignore rename to src/docs/.gitignore diff --git a/src/docs/cfg/footer.json b/src/docs/cfg/footer.json new file mode 100644 index 0000000..83694ed --- /dev/null +++ b/src/docs/cfg/footer.json @@ -0,0 +1,22 @@ +{ + "style": "dark", + "links": [ + { + "title": "Web", + "items": [ + { + "label": "ThreeFold.io", + "href": "https://threefold.io" + }, + { + "href": "https://mycelium.threefold.io/", + "label": "Mycelium Network" + }, + { + "href": "https://aibox.threefold.io/", + "label": "AI Box" + } + ] + } + ] +} diff --git a/docs/cfg/main.json b/src/docs/cfg/main.json similarity index 54% rename from docs/cfg/main.json rename to src/docs/cfg/main.json index 318cbb3..4361fa1 100644 --- a/docs/cfg/main.json +++ b/src/docs/cfg/main.json @@ -1,17 +1,17 @@ { - "title": "ThreeFold DePIN", - "tagline": "ThreeFold DePIN", + "title": "ThreeFold HeroScript", + "tagline": "ThreeFold HeroScript", "favicon": "img/favicon.png", - "url": "https://docs.threefold.io", - "url_home": "docs/introduction", - "baseUrl": "/", + "url": "https://threefold.info", + "url_home": "docs/intro", + "baseUrl": "/heroscript/", "image": "img/tf_graph.png", "metadata": { "description": "Internet Infrastructur for Everyone by Everyone, Everywhere.", "image": "https://threefold.info/tfgrid4/img/tf_graph.png", - "title": "ThreeFold DePIN" + "title": "ThreeFold" }, - "buildDest":["root@info.ourworld.tf:/root/hero/www/info/tfgrid4"], - "buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev/tfgrid4"], + "buildDest":["root@info.ourworld.tf:/root/hero/www/info/heroscript"], + "buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev/heroscript"], "copyright": "ThreeFold" } diff --git a/docs/cfg/navbar.json b/src/docs/cfg/navbar.json similarity index 100% rename from docs/cfg/navbar.json rename to src/docs/cfg/navbar.json diff --git a/src/docs/docs/intro.md b/src/docs/docs/intro.md new file mode 100644 index 0000000..8c6ae0b --- /dev/null +++ b/src/docs/docs/intro.md @@ -0,0 +1,7 @@ +--- +title: "intro" +sidebar_position: 1 +--- + +# HeroScript + diff --git a/src/docs/docs/sal/_category_.json b/src/docs/docs/sal/_category_.json new file mode 100644 index 0000000..1242583 --- /dev/null +++ b/src/docs/docs/sal/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "SAL", + "position": 6, + "link": { + "type": "generated-index", + "description": "Tools to work with operating system." + } + } \ No newline at end of file diff --git a/src/docs/subdir/buildah.md b/src/docs/docs/sal/buildah.md similarity index 96% rename from src/docs/subdir/buildah.md rename to src/docs/docs/sal/buildah.md index 13e7f00..dcb124b 100644 --- a/src/docs/subdir/buildah.md +++ b/src/docs/docs/sal/buildah.md @@ -1,4 +1,10 @@ -# Buildah Module +--- +title: "build containers" +sidebar_position: 20 +hide_title: true +--- + +# Buildah = container builder The Buildah module provides functions for working with containers and images using the Buildah tool. Buildah helps you create and manage container images. @@ -8,7 +14,7 @@ The Buildah module now supports a Builder pattern, which provides a more intuiti ### Creating a Builder -```rhai +```js // Create a builder with a name and base image let builder = bah_new("my-container", "alpine:latest"); @@ -39,7 +45,7 @@ The Builder object provides the following methods: ### Example -```rhai +```js // Create a builder let builder = bah_new("my-container", "alpine:latest"); @@ -90,7 +96,7 @@ Creates a new Builder object for working with a container. **Returns:** A Builder object if successful. **Example:** -```rhai +```js // Create a new Builder let builder = bah_new("my-container", "alpine:latest"); ``` @@ -106,7 +112,7 @@ Resets a Builder by removing the container and clearing the container_id. This a **Returns:** Nothing. **Example:** -```rhai +```js // Create a Builder let builder = bah_new("my-container", "alpine:latest"); diff --git a/src/docs/subdir/git.md b/src/docs/docs/sal/git.md similarity index 94% rename from src/docs/subdir/git.md rename to src/docs/docs/sal/git.md index 26c38b2..add1664 100644 --- a/src/docs/subdir/git.md +++ b/src/docs/docs/sal/git.md @@ -1,6 +1,12 @@ -# Git Module for Rhai +--- +title: "git" +sidebar_position: 5 +hide_title: true +--- -This module provides Rhai wrappers for the Git functionality in SAL. +# Git + +This module provides HeroScript wrappers for the Git functionality in SAL. > **Note:** The constructor for GitTree has been renamed from `new()` to `gittree_new()` to avoid confusion with other constructors. This makes the interface more explicit and less likely to cause naming conflicts. @@ -22,7 +28,7 @@ This design allows for a more intuitive and flexible interface, with method chai The GitTree object is the main entry point for git operations. It represents a collection of git repositories under a base path. -```rhai +```js // Create a new GitTree with a base path let git_tree = gittree_new("/root/code"); print(`Created GitTree with base path: /home/user/code`); @@ -32,7 +38,7 @@ print(`Created GitTree with base path: /home/user/code`); ### List All Repositories -```rhai +```js // List all git repositories under the base path let repos = git_tree.list(); print(`Found ${repos.len()} repositories`); @@ -45,7 +51,7 @@ for repo in repos { ### Find Repositories Matching a Pattern -```rhai +```js // Find repositories matching a pattern // Use a wildcard (*) suffix to find multiple matches let matching_repos = git_tree.find("my-project*"); @@ -63,7 +69,7 @@ print(`Found specific repository: ${specific_repo}`); ### Get Repository Objects -```rhai +```js // Get GitRepo objects for repositories matching a pattern let repos = git_tree.get("my-project*"); print(`Found ${repos.len()} repositories`); @@ -75,7 +81,7 @@ print(`Working with repository: ${repo.path()}`); ### Clone a Repository -```rhai +```js // Clone a repository by URL // This will clone the repository to the base path of the GitTree let repos = git_tree.get("https://github.com/username/repo.git"); @@ -85,7 +91,7 @@ print(`Repository cloned to: ${repo.path()}`); ### Check for Changes -```rhai +```js // Check if a repository has uncommitted changes let repo = git_tree.get("my-project")[0]; if repo.has_changes() { @@ -99,7 +105,7 @@ if repo.has_changes() { ### Pull Changes -```rhai +```js // Pull the latest changes from the remote // This will fail if there are uncommitted changes let repo = git_tree.get("my-project")[0]; @@ -109,7 +115,7 @@ print("Repository updated successfully"); ### Reset Local Changes -```rhai +```js // Reset any local changes in the repository let repo = git_tree.get("my-project")[0]; let result = repo.reset(); @@ -118,7 +124,7 @@ print("Repository reset successfully"); ### Commit Changes -```rhai +```js // Commit changes in the repository let repo = git_tree.get("my-project")[0]; let result = repo.commit("Fix bug in login form"); @@ -127,7 +133,7 @@ print("Changes committed successfully"); ### Push Changes -```rhai +```js // Push changes to the remote let repo = git_tree.get("my-project")[0]; let result = repo.push(); @@ -138,7 +144,7 @@ print("Changes pushed successfully"); The GitRepo methods can be chained together for more complex operations: -```rhai +```js // Commit changes and push them to the remote let repo = git_tree.get("my-project")[0]; let result = repo.commit("Add new feature").push(); @@ -152,7 +158,7 @@ print("Repository updated successfully"); ## Complete Example -```rhai +```js // Create a new GitTree let home_dir = env("HOME"); let git_tree = gittree_new(`${home_dir}/code`); @@ -181,11 +187,11 @@ for repo_path in all_repos { ## Error Handling -All methods in the Git module return a Result type, which means they can either succeed or fail with an error. If an error occurs, it will be propagated to the Rhai script as a runtime error. +All methods in the Git module return a Result type, which means they can either succeed or fail with an error. If an error occurs, it will be propagated to the HeroScript script as a runtime error. For example, if you try to clone a repository that doesn't exist: -```rhai +```js // Try to clone a non-existent repository try { let git_tree = gittree_new("/root/code"); diff --git a/src/docs/docs/sal/intro.md b/src/docs/docs/sal/intro.md new file mode 100644 index 0000000..9260342 --- /dev/null +++ b/src/docs/docs/sal/intro.md @@ -0,0 +1,10 @@ +--- +title: "intro" +sidebar_position: 1 +hide_title: true +--- + +## HeroScript Script Commands Documentation + + +The SAL library provides integration with the HeroScript scripting language, allowing you to use powerful system functions within your HeroScript scripts. These functions are organized into modules that provide related functionality. diff --git a/src/docs/subdir/os.md b/src/docs/docs/sal/os.md similarity index 96% rename from src/docs/subdir/os.md rename to src/docs/docs/sal/os.md index 8cc44c2..6bf2bcb 100644 --- a/src/docs/subdir/os.md +++ b/src/docs/docs/sal/os.md @@ -1,4 +1,10 @@ -# OS Module +--- +title: "os" +sidebar_position: 2 +hide_title: true +--- + +# OS Tools The OS module provides functions for working with files, directories, and downloading files from the internet. @@ -15,7 +21,7 @@ Recursively copies a file or directory from source to destination. **Returns:** A message confirming the copy was successful. **Example:** -```rhai +```js // Copy a file copy("source.txt", "destination.txt"); @@ -33,7 +39,7 @@ Checks if a file or directory exists. **Returns:** A boolean value - `true` if the file or directory exists, `false` otherwise. **Example:** -```rhai +```js if exist("config.json") { // File exists, do something } else { @@ -52,7 +58,7 @@ Finds a file in a directory with support for wildcards. **Returns:** The path of the first matching file. **Example:** -```rhai +```js // Find a specific file let config_file = find_file("./config", "settings.json"); @@ -71,7 +77,7 @@ Finds multiple files in a directory recursively with support for wildcards. **Returns:** A list of matching file paths. **Example:** -```rhai +```js // Find all JSON files let json_files = find_files("./data", "*.json"); @@ -92,7 +98,7 @@ Finds a directory in a parent directory with support for wildcards. **Returns:** The path of the first matching directory. **Example:** -```rhai +```js // Find a specific directory let config_dir = find_dir("./", "config"); @@ -111,7 +117,7 @@ Finds multiple directories in a parent directory recursively with support for wi **Returns:** A list of matching directory paths. **Example:** -```rhai +```js // Find all version directories let version_dirs = find_dirs("./releases", "v*"); @@ -131,7 +137,7 @@ Deletes a file or directory. This function is defensive and doesn't error if the **Returns:** A message confirming the deletion was successful. **Example:** -```rhai +```js // Delete a file delete("temp.txt"); @@ -149,7 +155,7 @@ Creates a directory and all parent directories. This function is defensive and d **Returns:** A message confirming the directory was created. **Example:** -```rhai +```js // Create a directory mkdir("new_dir"); @@ -167,7 +173,7 @@ Gets the size of a file in bytes. **Returns:** The size of the file in bytes. **Example:** -```rhai +```js // Get file size let size = file_size("large_file.dat"); print(`File size: ${size} bytes`); @@ -185,7 +191,7 @@ Reads the contents of a file. **Returns:** The content of the file as a string. **Example:** -```rhai +```js // Read a file let content = file_read("config.json"); print(`File content: ${content}`); @@ -202,7 +208,7 @@ Writes content to a file. Creates the file if it doesn't exist, overwrites if it **Returns:** A message confirming the file was written. **Example:** -```rhai +```js // Write to a file file_write("config.json", "{\n \"setting\": \"value\"\n}"); ``` @@ -218,7 +224,7 @@ Appends content to a file. Creates the file if it doesn't exist. **Returns:** A message confirming the content was appended. **Example:** -```rhai +```js // Append to a log file file_write_append("log.txt", "New log entry\n"); ``` @@ -234,7 +240,7 @@ Syncs directories using rsync (or platform equivalent). **Returns:** A message confirming the directories were synced. **Example:** -```rhai +```js // Sync directories rsync("source_dir", "backup_dir"); ``` @@ -249,7 +255,7 @@ Changes the current working directory. **Returns:** A message confirming the directory was changed. **Example:** -```rhai +```js // Change directory chdir("project/src"); ``` @@ -274,7 +280,7 @@ Downloads a file from a URL to a destination using the curl command. If the URL **Returns:** The path where the file was saved or extracted. **Example:** -```rhai +```js // Download a file download("https://example.com/file.zip", "downloads/file.zip", 10); ``` @@ -293,6 +299,6 @@ Downloads a file and installs it if it's a supported package format. **Returns:** The path where the file was saved or installed. **Example:** -```rhai +```js // Download and install a package download_install("https://example.com/package.deb", 1000); \ No newline at end of file diff --git a/src/docs/subdir/process.md b/src/docs/docs/sal/process.md similarity index 97% rename from src/docs/subdir/process.md rename to src/docs/docs/sal/process.md index 8f49ff2..14b3327 100644 --- a/src/docs/subdir/process.md +++ b/src/docs/docs/sal/process.md @@ -1,3 +1,9 @@ +--- +title: "process" +sidebar_position: 3 +hide_title: true +--- + # Process Module The Process module provides functions for running commands and managing processes on your system. @@ -33,7 +39,7 @@ Runs a command or multiline script with arguments. **Returns:** The result of the command, including output and whether it succeeded. **Example 1: Running a simple command** -```rhai +```js // Run a simple command let result = run("ls -la"); @@ -46,7 +52,7 @@ if result.success { ``` **Example 2: Running a multiline script** -```rhai +```js // Create a multiline script using backtick string literals let setup_script = ` # Create directories @@ -80,7 +86,7 @@ Runs a command or multiline script with arguments silently (without displaying o **Example:** -```rhai +```js // Run a command silently let result = run_silent("git pull"); @@ -103,7 +109,7 @@ Creates a new map with default run options. - `log` (boolean): `false` - Whether to log the command execution **Example:** -```rhai +```js // Create run options let options = new_run_options(); ``` @@ -119,7 +125,7 @@ Runs a command with options specified in a map. **Returns:** The result of the command with your custom settings applied. **Example:** -```rhai +```js // Create and customize run options let options = new_run_options(); options.die = false; // Don't throw an error if the command fails @@ -137,9 +143,9 @@ The Process module allows you to execute multiline scripts, which is particularl ### Creating Multiline Scripts -Multiline scripts can be created using backtick (`) string literals in Rhai: +Multiline scripts can be created using backtick (`) string literals in HeroScript: -```rhai +```js let my_script = ` # This is a multiline bash script echo "Hello, World!" @@ -161,7 +167,7 @@ Checks if a command exists in the PATH. **Returns:** The full path to the command if found, or nothing if not found. **Example:** -```rhai +```js // Check if a command exists let git_path = which("git"); @@ -182,7 +188,7 @@ Kills processes matching a pattern. **Returns:** A message confirming the processes were killed. **Example:** -```rhai +```js // Kill all processes with "node" in their name kill("node"); ``` @@ -197,7 +203,7 @@ Lists processes matching a pattern (or all processes if the pattern is empty). **Returns:** A list of processes matching your search. **Example:** -```rhai +```js // List all processes let all_processes = process_list(""); @@ -220,7 +226,7 @@ Gets a single process matching the pattern. Throws an error if zero or more than **Returns:** Information about the matching process. This will only work if exactly one process matches. **Example:** -```rhai +```js // Try to get a specific process try { let process = process_get("my_app"); diff --git a/src/docs/subdir/README.md b/src/docs/subdir/README.md deleted file mode 100644 index abf9269..0000000 --- a/src/docs/subdir/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Rhai Script Commands Documentation - -This documentation provides detailed information about the Rhai script commands available in the SAL library. The commands are organized by module for easy reference. - -## Modules - -- [OS Module](os.md) - File system operations, directory management, and download functions -- [Process Module](process.md) - Command execution and process management -- [Buildah Module](buildah.md) - Container and image management - -## Overview - -The SAL library provides integration with the Rhai scripting language, allowing you to use powerful system functions within your Rhai scripts. These functions are organized into modules that provide related functionality. - -### Using Rhai in Your Projects - -To use these commands in your Rhai scripts, you need to register the SAL modules with your Rhai engine: - -```rust -use rhai::Engine; -use sal::rhai; - -let mut engine = Engine::new(); -rhai::register(&mut engine); - -// Now you can use SAL functions in Rhai scripts -let result = engine.eval::("exist('some_file.txt')").unwrap(); -``` - -This will register all available modules (OS, Process, and Buildah) with your Rhai engine. \ No newline at end of file diff --git a/src/docs/subdir/_category_.json b/src/docs/subdir/_category_.json deleted file mode 100644 index 17ee60b..0000000 --- a/src/docs/subdir/_category_.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "label": "Become a Farmer", - "position": 6, - "link": { - "type": "generated-index", - "description": "Learn how to become a farmer. Let's together build Web4 everywhere for everyone." - } - } \ No newline at end of file diff --git a/src/docs/tech.md b/src/docs/tech.md deleted file mode 100644 index 91739b4..0000000 --- a/src/docs/tech.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -sidebar_position: 10 ---- - -# Technology - -![](img/threefold_parts.png) - - -ThreeFold delivers the plumbing layer for a better Internet which has the potential to achieve Augmented Collective Intelligence[^1]. We call such a system **Web4**. - -> *ThreeFold might be the only platform in the world providing Web4 network, data and cloud capabilities in one system.* - -## 3 Required Levels - -Together with our partners, we have all the required parts to make it happen on 3 major levels: - -### Personal Level - -- **Agent Layer**: Every person owns a Personal Digital Assistant (PDA), managing their digital life. -- **Identity Layer**: Strong reputation management, proof of authenticity, a global name system. -- **Intelligence Layer**: Decentralized, personal AI systems for collaboration & augmented intelligence. -- **Transaction Layer**: Fully integrated with Web3 systems and beyond, e.g. mutual credit, etc. - - -### Infrastructure Level - -- **Network Layer**: Redesign of how communication happens with a private and more scalable network layer. -- **Data Layer**: Redesign of how we share, distribute and store data. -- **Serverless Compute Layer**: Allow code to run close to where participants and data are. -- **Cloud Layer**: Run VMs and containers as part of the ecosystem with Web2 compatibility layer. - -### Physical Level - -- **Routers**: Route between old and new web, and create new secure communication channels. -- **Nodes**: Deliver AI, Data, Compute to the ecosystem. -- **Phones**: Our personal device, capable of building a meshed network, offline support with catchup. -- **Computers**: Any current Linux, Windows, macOS computer seamlessly integrates. - -![](img/zos.png) - -The following are the required components to make all this possible: - -- **Zero-OS**: Custom lightweight operating system for nodes built on the Linux kernel. - - Self-healing and automated resource management via bare metal ThreeFold nodes. -- **Mycelium**: End-to-end encrypted network always using the shortest path. -- **Quantum Safe Storage**: Technology resistant to quantum computer attacks where data can never be lost. -- **Advanced AI Agent**: Creation of apps fully compatibility with Web3. -- **Smart Contract for IT**: Blockchain-based resource allocation with signed contracts. - - Secure, transparent transaction mechanisms for deployment of solutions on the ThreeFold Grid. - -> For more information, read the [ThreeFold Tech ebook](https://threefold.info/tech). - -[^1]: Augmented Collective Intelligence - Supermind [Link](https://www.supermind.design/)