This commit is contained in:
despiegk 2025-04-05 07:23:00 +02:00
parent 6de7bf9b56
commit 5fec3b967b
15 changed files with 128 additions and 221 deletions

View File

@ -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"
}
]
}
]
}

22
src/docs/cfg/footer.json Normal file
View File

@ -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"
}
]
}
]
}

View File

@ -1,17 +1,17 @@
{ {
"title": "ThreeFold DePIN", "title": "ThreeFold HeroScript",
"tagline": "ThreeFold DePIN", "tagline": "ThreeFold HeroScript",
"favicon": "img/favicon.png", "favicon": "img/favicon.png",
"url": "https://docs.threefold.io", "url": "https://threefold.info",
"url_home": "docs/introduction", "url_home": "docs/intro",
"baseUrl": "/", "baseUrl": "/heroscript/",
"image": "img/tf_graph.png", "image": "img/tf_graph.png",
"metadata": { "metadata": {
"description": "Internet Infrastructur for Everyone by Everyone, Everywhere.", "description": "Internet Infrastructur for Everyone by Everyone, Everywhere.",
"image": "https://threefold.info/tfgrid4/img/tf_graph.png", "image": "https://threefold.info/tfgrid4/img/tf_graph.png",
"title": "ThreeFold DePIN" "title": "ThreeFold"
}, },
"buildDest":["root@info.ourworld.tf:/root/hero/www/info/tfgrid4"], "buildDest":["root@info.ourworld.tf:/root/hero/www/info/heroscript"],
"buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev/tfgrid4"], "buildDestDev":["root@info.ourworld.tf:/root/hero/www/infodev/heroscript"],
"copyright": "ThreeFold" "copyright": "ThreeFold"
} }

7
src/docs/docs/intro.md Normal file
View File

@ -0,0 +1,7 @@
---
title: "intro"
sidebar_position: 1
---
# HeroScript

View File

@ -0,0 +1,8 @@
{
"label": "SAL",
"position": 6,
"link": {
"type": "generated-index",
"description": "Tools to work with operating system."
}
}

View File

@ -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. 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 ### Creating a Builder
```rhai ```js
// Create a builder with a name and base image // Create a builder with a name and base image
let builder = bah_new("my-container", "alpine:latest"); let builder = bah_new("my-container", "alpine:latest");
@ -39,7 +45,7 @@ The Builder object provides the following methods:
### Example ### Example
```rhai ```js
// Create a builder // Create a builder
let builder = bah_new("my-container", "alpine:latest"); 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. **Returns:** A Builder object if successful.
**Example:** **Example:**
```rhai ```js
// Create a new Builder // Create a new Builder
let builder = bah_new("my-container", "alpine:latest"); 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. **Returns:** Nothing.
**Example:** **Example:**
```rhai ```js
// Create a Builder // Create a Builder
let builder = bah_new("my-container", "alpine:latest"); let builder = bah_new("my-container", "alpine:latest");

View File

@ -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. > **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. 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 // Create a new GitTree with a base path
let git_tree = gittree_new("/root/code"); let git_tree = gittree_new("/root/code");
print(`Created GitTree with base path: /home/user/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 ### List All Repositories
```rhai ```js
// List all git repositories under the base path // List all git repositories under the base path
let repos = git_tree.list(); let repos = git_tree.list();
print(`Found ${repos.len()} repositories`); print(`Found ${repos.len()} repositories`);
@ -45,7 +51,7 @@ for repo in repos {
### Find Repositories Matching a Pattern ### Find Repositories Matching a Pattern
```rhai ```js
// Find repositories matching a pattern // Find repositories matching a pattern
// Use a wildcard (*) suffix to find multiple matches // Use a wildcard (*) suffix to find multiple matches
let matching_repos = git_tree.find("my-project*"); let matching_repos = git_tree.find("my-project*");
@ -63,7 +69,7 @@ print(`Found specific repository: ${specific_repo}`);
### Get Repository Objects ### Get Repository Objects
```rhai ```js
// Get GitRepo objects for repositories matching a pattern // Get GitRepo objects for repositories matching a pattern
let repos = git_tree.get("my-project*"); let repos = git_tree.get("my-project*");
print(`Found ${repos.len()} repositories`); print(`Found ${repos.len()} repositories`);
@ -75,7 +81,7 @@ print(`Working with repository: ${repo.path()}`);
### Clone a Repository ### Clone a Repository
```rhai ```js
// Clone a repository by URL // Clone a repository by URL
// This will clone the repository to the base path of the GitTree // This will clone the repository to the base path of the GitTree
let repos = git_tree.get("https://github.com/username/repo.git"); let repos = git_tree.get("https://github.com/username/repo.git");
@ -85,7 +91,7 @@ print(`Repository cloned to: ${repo.path()}`);
### Check for Changes ### Check for Changes
```rhai ```js
// Check if a repository has uncommitted changes // Check if a repository has uncommitted changes
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
if repo.has_changes() { if repo.has_changes() {
@ -99,7 +105,7 @@ if repo.has_changes() {
### Pull Changes ### Pull Changes
```rhai ```js
// Pull the latest changes from the remote // Pull the latest changes from the remote
// This will fail if there are uncommitted changes // This will fail if there are uncommitted changes
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
@ -109,7 +115,7 @@ print("Repository updated successfully");
### Reset Local Changes ### Reset Local Changes
```rhai ```js
// Reset any local changes in the repository // Reset any local changes in the repository
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
let result = repo.reset(); let result = repo.reset();
@ -118,7 +124,7 @@ print("Repository reset successfully");
### Commit Changes ### Commit Changes
```rhai ```js
// Commit changes in the repository // Commit changes in the repository
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
let result = repo.commit("Fix bug in login form"); let result = repo.commit("Fix bug in login form");
@ -127,7 +133,7 @@ print("Changes committed successfully");
### Push Changes ### Push Changes
```rhai ```js
// Push changes to the remote // Push changes to the remote
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
let result = repo.push(); let result = repo.push();
@ -138,7 +144,7 @@ print("Changes pushed successfully");
The GitRepo methods can be chained together for more complex operations: The GitRepo methods can be chained together for more complex operations:
```rhai ```js
// Commit changes and push them to the remote // Commit changes and push them to the remote
let repo = git_tree.get("my-project")[0]; let repo = git_tree.get("my-project")[0];
let result = repo.commit("Add new feature").push(); let result = repo.commit("Add new feature").push();
@ -152,7 +158,7 @@ print("Repository updated successfully");
## Complete Example ## Complete Example
```rhai ```js
// Create a new GitTree // Create a new GitTree
let home_dir = env("HOME"); let home_dir = env("HOME");
let git_tree = gittree_new(`${home_dir}/code`); let git_tree = gittree_new(`${home_dir}/code`);
@ -181,11 +187,11 @@ for repo_path in all_repos {
## Error Handling ## 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: For example, if you try to clone a repository that doesn't exist:
```rhai ```js
// Try to clone a non-existent repository // Try to clone a non-existent repository
try { try {
let git_tree = gittree_new("/root/code"); let git_tree = gittree_new("/root/code");

View File

@ -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.

View File

@ -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. 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. **Returns:** A message confirming the copy was successful.
**Example:** **Example:**
```rhai ```js
// Copy a file // Copy a file
copy("source.txt", "destination.txt"); 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. **Returns:** A boolean value - `true` if the file or directory exists, `false` otherwise.
**Example:** **Example:**
```rhai ```js
if exist("config.json") { if exist("config.json") {
// File exists, do something // File exists, do something
} else { } else {
@ -52,7 +58,7 @@ Finds a file in a directory with support for wildcards.
**Returns:** The path of the first matching file. **Returns:** The path of the first matching file.
**Example:** **Example:**
```rhai ```js
// Find a specific file // Find a specific file
let config_file = find_file("./config", "settings.json"); 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. **Returns:** A list of matching file paths.
**Example:** **Example:**
```rhai ```js
// Find all JSON files // Find all JSON files
let json_files = find_files("./data", "*.json"); 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. **Returns:** The path of the first matching directory.
**Example:** **Example:**
```rhai ```js
// Find a specific directory // Find a specific directory
let config_dir = find_dir("./", "config"); 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. **Returns:** A list of matching directory paths.
**Example:** **Example:**
```rhai ```js
// Find all version directories // Find all version directories
let version_dirs = find_dirs("./releases", "v*"); 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. **Returns:** A message confirming the deletion was successful.
**Example:** **Example:**
```rhai ```js
// Delete a file // Delete a file
delete("temp.txt"); 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. **Returns:** A message confirming the directory was created.
**Example:** **Example:**
```rhai ```js
// Create a directory // Create a directory
mkdir("new_dir"); mkdir("new_dir");
@ -167,7 +173,7 @@ Gets the size of a file in bytes.
**Returns:** The size of the file in bytes. **Returns:** The size of the file in bytes.
**Example:** **Example:**
```rhai ```js
// Get file size // Get file size
let size = file_size("large_file.dat"); let size = file_size("large_file.dat");
print(`File size: ${size} bytes`); print(`File size: ${size} bytes`);
@ -185,7 +191,7 @@ Reads the contents of a file.
**Returns:** The content of the file as a string. **Returns:** The content of the file as a string.
**Example:** **Example:**
```rhai ```js
// Read a file // Read a file
let content = file_read("config.json"); let content = file_read("config.json");
print(`File content: ${content}`); 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. **Returns:** A message confirming the file was written.
**Example:** **Example:**
```rhai ```js
// Write to a file // Write to a file
file_write("config.json", "{\n \"setting\": \"value\"\n}"); 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. **Returns:** A message confirming the content was appended.
**Example:** **Example:**
```rhai ```js
// Append to a log file // Append to a log file
file_write_append("log.txt", "New log entry\n"); 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. **Returns:** A message confirming the directories were synced.
**Example:** **Example:**
```rhai ```js
// Sync directories // Sync directories
rsync("source_dir", "backup_dir"); rsync("source_dir", "backup_dir");
``` ```
@ -249,7 +255,7 @@ Changes the current working directory.
**Returns:** A message confirming the directory was changed. **Returns:** A message confirming the directory was changed.
**Example:** **Example:**
```rhai ```js
// Change directory // Change directory
chdir("project/src"); 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. **Returns:** The path where the file was saved or extracted.
**Example:** **Example:**
```rhai ```js
// Download a file // Download a file
download("https://example.com/file.zip", "downloads/file.zip", 10); 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. **Returns:** The path where the file was saved or installed.
**Example:** **Example:**
```rhai ```js
// Download and install a package // Download and install a package
download_install("https://example.com/package.deb", 1000); download_install("https://example.com/package.deb", 1000);

View File

@ -1,3 +1,9 @@
---
title: "process"
sidebar_position: 3
hide_title: true
---
# Process Module # Process Module
The Process module provides functions for running commands and managing processes on your system. 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. **Returns:** The result of the command, including output and whether it succeeded.
**Example 1: Running a simple command** **Example 1: Running a simple command**
```rhai ```js
// Run a simple command // Run a simple command
let result = run("ls -la"); let result = run("ls -la");
@ -46,7 +52,7 @@ if result.success {
``` ```
**Example 2: Running a multiline script** **Example 2: Running a multiline script**
```rhai ```js
// Create a multiline script using backtick string literals // Create a multiline script using backtick string literals
let setup_script = ` let setup_script = `
# Create directories # Create directories
@ -80,7 +86,7 @@ Runs a command or multiline script with arguments silently (without displaying o
**Example:** **Example:**
```rhai ```js
// Run a command silently // Run a command silently
let result = run_silent("git pull"); 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 - `log` (boolean): `false` - Whether to log the command execution
**Example:** **Example:**
```rhai ```js
// Create run options // Create run options
let options = new_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. **Returns:** The result of the command with your custom settings applied.
**Example:** **Example:**
```rhai ```js
// Create and customize run options // Create and customize run options
let options = new_run_options(); let options = new_run_options();
options.die = false; // Don't throw an error if the command fails 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 ### 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 = ` let my_script = `
# This is a multiline bash script # This is a multiline bash script
echo "Hello, World!" 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. **Returns:** The full path to the command if found, or nothing if not found.
**Example:** **Example:**
```rhai ```js
// Check if a command exists // Check if a command exists
let git_path = which("git"); let git_path = which("git");
@ -182,7 +188,7 @@ Kills processes matching a pattern.
**Returns:** A message confirming the processes were killed. **Returns:** A message confirming the processes were killed.
**Example:** **Example:**
```rhai ```js
// Kill all processes with "node" in their name // Kill all processes with "node" in their name
kill("node"); 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. **Returns:** A list of processes matching your search.
**Example:** **Example:**
```rhai ```js
// List all processes // List all processes
let all_processes = process_list(""); 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. **Returns:** Information about the matching process. This will only work if exactly one process matches.
**Example:** **Example:**
```rhai ```js
// Try to get a specific process // Try to get a specific process
try { try {
let process = process_get("my_app"); let process = process_get("my_app");

View File

@ -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::<bool>("exist('some_file.txt')").unwrap();
```
This will register all available modules (OS, Process, and Buildah) with your Rhai engine.

View File

@ -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."
}
}

View File

@ -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/)