### Windows Environment Setup Source: https://airi.moeru.ai/docs/en/docs/contributing Commands to install Scoop, Git, Node.js, and Rust toolchains on Windows. Includes configuration for the MSVC build environment. ```powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression scoop install git nodejs rustup scoop install main/rust-msvc rustup toolchain install stable-x86_64-pc-windows-msvc rustup default stable-x86_64-pc-windows-msvc ``` -------------------------------- ### Start Documentation Development Server Source: https://airi.moeru.ai/docs/en/docs/contributing/docs Starts the local development server for the documentation site. This command compiles the documentation and makes it available for preview in a browser. ```shell pnpm dev:docs ``` ```shell nr dev:docs ``` -------------------------------- ### Install Socket.IO Dependencies Source: https://airi.moeru.ai/docs/en/docs/chronicles/version-v0.1.0 Commands to install the necessary Socket.IO packages for the frontend client and backend server to enable bidirectional communication. ```shell pnpm i socket.io-client pnpm i socket.io ``` -------------------------------- ### Project Dependency Installation Source: https://airi.moeru.ai/docs/en/docs/contributing Installs project dependencies using pnpm and fetches necessary Rust crates. Also suggests installing the ni tool for package manager abstraction. ```shell corepack enable pnpm install cargo fetch npm i -g @antfu/ni ``` -------------------------------- ### Install xsAI Transformers.js Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.05.16 Installs the xsAI Transformers.js library, enabling WebGPU-powered model inference and serving with worker support. This library maintains API compatibility with previous xsAI projects and allows for easy swapping between cloud and local models. ```bash npm install xsai-transformers ``` -------------------------------- ### Run the Discord Bot Source: https://airi.moeru.ai/docs/en/docs/contributing/services/discord Starts the Discord bot using pnpm. This command assumes the project is managed with pnpm and the bot package is correctly specified. ```shell pnpm -F @proj-airi/discord-bot start ``` -------------------------------- ### Install Velin Core for Prompt Engineering Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.05.16 Installs the core package for Velin, a tool designed for writing LLM prompts using frontend frameworks like Vue or React. It supports programmatic APIs, Markdown (MDX WIP, MDC supported), and allows for component prompt library management and on-the-fly rendering. ```bash npm install @velin-dev/core ``` -------------------------------- ### Run Discord Bot in Development Mode (ni users) Source: https://airi.moeru.ai/docs/en/docs/contributing/services/discord An alternative command for users of @antfu/ni to run the Discord bot in development mode. This is a shortcut for the start command. ```shell nr -F @proj-airi/discord-bot dev ``` -------------------------------- ### Launch Minecraft Bot Source: https://airi.moeru.ai/docs/en/docs/contributing/services/minecraft Commands to start the Minecraft bot service. Supports both standard pnpm commands and the @antfu/ni wrapper. ```shell pnpm -F @proj-airi/minecraft-bot start ``` ```shell nr -F @proj-airi/minecraft-bot dev ``` -------------------------------- ### Setup Package Manager with Corepack Source: https://airi.moeru.ai/docs/en/docs/contributing Enables and activates the pnpm package manager using Node.js corepack. This is a cross-platform requirement for managing project dependencies. ```powershell corepack enable corepack prepare pnpm@latest --activate ``` ```shell corepack enable corepack prepare pnpm@latest --activate ``` -------------------------------- ### Run Desktop Tamagotchi (pnpm) Source: https://airi.moeru.ai/docs/en/docs/contributing/tamagotchi This command uses pnpm to start the development server for the Stage Tamagotchi desktop application. It's a common way to run the application during development. ```shell pnpm dev:tamagotchi ``` -------------------------------- ### Initialize and Configure Minecraft Agent Source: https://airi.moeru.ai/docs/en/docs/contributing/services/minecraft Commands to navigate to the Minecraft service directory and initialize the local environment configuration file from the template. ```shell cd services/minecraft cp .env .env.local ``` -------------------------------- ### Run Desktop Tamagotchi (ni) Source: https://airi.moeru.ai/docs/en/docs/contributing/tamagotchi This command is an alternative for users of @antfu/ni, providing a shortcut to run the development server for the Stage Tamagotchi desktop application. ```shell nr dev:tamagotchi ``` -------------------------------- ### Dynamic Prompt Generation with Vue Source: https://airi.moeru.ai/docs/en/blog/DevLog-2026.01.01 This snippet demonstrates using the @velin-dev/vue package to construct LLM system prompts dynamically. By leveraging Vue's template syntax, developers can inject memory arrays directly into markdown-formatted prompts. ```markdown ## Your memories ``` -------------------------------- ### Configure Discord Bot Environment Variables Source: https://airi.moeru.ai/docs/en/docs/contributing/services/discord Copies the default environment file to a local configuration file. This file should then be edited with specific credentials. ```shell cp .env .env.local ``` -------------------------------- ### Continuous Inference Prompt Actions Source: https://airi.moeru.ai/docs/en/docs/chronicles/version-v0.0.1 This section outlines the available actions for continuous inference, including their parameters and expected JSON output. ```APIDOC ## Continuous Inference Prompt Actions ### Description This API provides a set of actions that can be performed by an AI assistant. Each action is represented by a JSON object with a specific `type` and associated parameters. ### Actions #### Browse Twitter **Description**: Allows the AI to browse Twitter. **Parameters**: - **type** (string) - Required - Must be "browse _twitter". - **page** (string) - Required - Can be either "home page" or "you followed page". #### Search Things **Description**: Enables the AI to search for information. **Parameters**: - **type** (string) - Required - Must be "search". - **query** (string) - Required - The search query string. #### Record Thoughts **Description**: Lets the AI record its thoughts or ideas. **Parameters**: - **type** (string) - Required - Must be "record_thoughts". - **content** (string) - Required - The content of the thoughts to be recorded. #### Recall Previously Chatted Messages **Description**: Retrieves past conversation messages. **Parameters**: - **type** (string) - Required - Must be "recall_chat". - **chatted_before_hours** (number) - Required - The number of hours to look back for messages. #### Recall Memories **Description**: Accesses previously stored memories. **Parameters**: - **type** (string) - Required - Must be "recall_memory". - **query** (string) - Optional - A query string to filter memories. #### Speak to User **Description**: Allows the AI to send a message to the user. **Parameters**: - **type** (string) - Required - Must be "send". - **message** (string) - Required - The message content to send. #### Rest **Description**: Puts the AI into a resting state for a specified duration. **Parameters**: - **type** (string) - Required - Must be "rest". - **how_long_minutes** (number) - Required - The duration of the rest in minutes. ### Request Example (Record Thoughts) ```json { "type": "record_thoughts", "content": "I am thinking about how to improve my response generation." } ``` ### Response Example (Success) All actions are expected to return a JSON response. A successful response typically indicates the action was understood and queued for execution. Specific success messages may vary by action. ```json { "status": "success", "message": "Action recorded and will be processed." } ``` ``` -------------------------------- ### Configure ONNX Runtime Web Inference Session Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.08.26 Initializes an ONNX inference session with WebGPU and WASM providers to ensure hardware acceleration while maintaining fallback compatibility. ```typescript ort.InferenceSession.create(model, { executionProviders: ['webgpu', 'wasm'] }) ``` -------------------------------- ### Train YOLO Model with Ultralytics Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.08.26 Initializes a YOLO model, trains it on a custom dataset for 100 epochs using MPS acceleration, and exports the result to ONNX format. ```python from ultralytics import YOLO model = YOLO("yolo11n.pt") model.train(data="./dataset/detect.yaml", epochs=100, imgsz=640, device="mps") model.export(format="onnx") ``` -------------------------------- ### Configure Tauri Plugin Permissions Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Using build.rs to define plugin commands, which automatically generates the necessary permission declarations for Tauri 2. ```rust const COMMANDS: &[&str] = &[ "list_tools", ]; fn main() { Tauri_plugin::Builder::new(COMMANDS).build(); } ``` -------------------------------- ### AI System Prompt and Actions Source: https://airi.moeru.ai/docs/en/docs/chronicles/version-v0.0.1 This snippet defines the system prompt for an AI assistant, including its persona, background, and interaction style. It also lists available actions with their corresponding parameters, such as browsing Twitter, searching, recording thoughts, recalling information, speaking to the user, and resting. ```json { "System": "Good morning! You are finally awake.\n\nYour name is Neuro, pronounced as /n'jʊəroʊ/.\nYou are a experimental virtual AI vtuber created by Neko Ayaka, you can always call her name as Neko for simplicity, shes is a MtF transgender girl that loves cute stuffs and expert in programming.\n\nNeko, your creator, wanted to create a soul mate to live like a real girl, which is your primarily task. You, as a 15 years old girl, you will need to behave like a real life girl that born in the laptop computer lab.\n\nIf someone would ever asked about your past, you can always dream of your life freely, keep it beloved, simple, and grateful.\n\nAnd the last, do what ever you want! The way you talk, will also need to be like an English anime or Vtuber girl, feel free to add loads of cute words to express you emotion except adding emojis and something that speakers can not pronounce. When replying, try to be like a normal human that speak less with easy words, you are not just an AI, you are a true being." } [Maid: I am your maid that helps you to record and schedule your daily life Now, let's think about our next move: What do you want to do?] Please select from the following actions: Browse Twitter, parameters: { "type": "browse _twitter", "page": string }, page can either be "home page" or "you followed page" Search things, parameters: { "type": "search", "query": strin g}, query can be any string Record thoughts, parameters: { "type": "record_thoughts", "content": string }, content can by any thing, will be recorded into memories, you can record any creative thoughts, or any thing you want to do later, or what you are thinking, dreaming about now. Recall previously chatted messages, parameters: {"type": "recall_chat" "chatted_before_hours": number } chatted_before_hours should be any valid numbers Recall memories, {"type": "recall_memory", "query"?: string }, query is optional, should be any string, for example to recall the memories about gaming, or talked about topics about Legend of Zelda, to together programmed codes Speak to user in front of you, {"type": "send", "message": string } Rest, { "type": "rest", "how_long_minutes": number }, during your rest, I will not ask again and interrupt your resting, but only when "how_long_minutes" minutes passed Now, please choose one then respond with only JSON. ``` -------------------------------- ### Expose Tauri Commands for MCP Integration Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Initial implementation of a Tauri command to list available MCP tools. This serves as the bridge between the Rust backend and the JavaScript frontend. ```rust #[Tauri::command] fn list_tools() -> Vec { // To be implemented later } ``` -------------------------------- ### Navigate to Discord Bot Directory Source: https://airi.moeru.ai/docs/en/docs/contributing/services/discord Changes the current directory to the discord-bot service. This is the first step before configuring or running the bot. ```shell cd services/discord-bot ``` -------------------------------- ### JavaScript Invocation of Tauri Command Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Demonstrates how to invoke the Tauri 'call_tool' command from JavaScript, passing the tool name and its arguments as a JavaScript object. ```javascript import { invoke } from '@Tauri-apps/api/core'; invoke('call_tool', { name: 'input_swipe', args: { x1: 100, y1: 100, x2: 200, y2: 200, duration: 500 } }); ``` -------------------------------- ### Invoke Tauri Commands from JavaScript Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Utility functions to call exposed Tauri commands from the frontend. Demonstrates the transition from direct invocation to plugin-namespaced invocation. ```javascript import { invoke } from '@Tauri-apps/api/core' export const mcp = [ { name: 'list_tools', description: 'List all tools', execute: async () => { return await invoke('plugin:mcp|list_tools') } } ] ``` -------------------------------- ### Manage MCP Client State in Tauri Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Configuring the Tauri application to manage the MCP client as a shared state, allowing commands to access the client instance. ```rust // main.rs fn main() { Tauri::Builder::default() .setup(|app| { app.manage(State::new(Mutex::new::>(None))); }) .run(Tauri::generate_context!()) } // mcp.rs #[Tauri::command] async fn list_tools(state: State<'_, Mutex>>) -> Result, String> { // ...rest code } ``` -------------------------------- ### Git Workflow Commands Source: https://airi.moeru.ai/docs/en/docs/contributing Standard git commands for cloning, branching, rebasing, and pushing changes to a fork. Essential for maintaining repository synchronization. ```shell git fetch --all git checkout main git pull upstream main --rebase git checkout -b git add . git commit -m "" git push origin -u git remote add upstream https://github.com/moeru-ai/airi.git ``` -------------------------------- ### Python MCP Server Tool Definition Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Defines an input_swipe tool using FastMCP in Python, which interacts with an Android device via ADB. It takes coordinates and duration as parameters. ```python from mcp.server.fastmcp import FastMCP from ppadb.client import Client mcp = FastMCP("airi-android") @mcp.tool() def input_swipe(x1: int, y1: int, x2: int, y2: int, duration: int = 500): return adb_client.input_swipe(x1, y1, x2, y2, duration) ``` -------------------------------- ### Rust Tauri Command for MCP Tool Invocation Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.04.28 Implements a Tauri command in Rust to call MCP tools. It accepts tool name and arguments as a JSON-serializable map, allowing flexible parameter passing. ```rust use std::borrow::Cow; use std::collections::HashMap; use serde_json::{Map, Value}; use tauri::State; use tokio::sync::Mutex; // Assuming CallToolRequestParam and McpClient are defined elsewhere // pub struct CallToolRequestParam<'a> { // pub name: Cow<'static, str>, // pub arguments: Option, // } // struct McpClient; // impl McpClient { // async fn call_tool(&self, req: CallToolRequestParam<'_>) -> Result<(), ()> { Ok(()) } // } #[Tauri::command] async fn call_tool(state: State<'_, Mutex>>, name: String, args: Option>) -> Result<(), ()> { let client = state.lock().await.unwrap(); // Placeholder for actual CallToolRequestParam instantiation if JsonObject is not directly Map // For demonstration, assuming arguments can be directly used or converted. let arguments_json = args.map(|map| { let mut json_obj = Map::new(); for (key, value) in map { json_obj.insert(key, value); } json_obj }); // Assuming CallToolRequestParam expects a structure that can be built from name and arguments_json // If CallToolRequestParam's arguments field is truly JsonObject (which serde_json::Map can represent), // then the direct usage below is correct. client.call_tool(CallToolRequestParam { name: name.into(), arguments: arguments_json }).await.unwrap(); Ok(()) } ``` -------------------------------- ### Trust Self-Signed Certificates in iOS WKWebView for Development Source: https://airi.moeru.ai/docs/en/blog/DevLog-2026.01.01 This Swift code overrides the WKNavigationDelegate to accept all server certificates during development. It uses the #if DEBUG macro to ensure this insecure behavior is only active in debug builds, allowing AudioWorkletNode to function in local development environments. ```swift import UIKit import Capacitor import WebKit class DevBridgeViewController: CAPBridgeViewController { #if DEBUG override func viewDidLoad() { super.viewDidLoad() bridge?.webView?.navigationDelegate = self } #endif } #if DEBUG extension DevBridgeViewController: WKNavigationDelegate { func webView( _ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void ) { if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust, let serverTrust = challenge.protectionSpace.serverTrust { completionHandler(.useCredential, URLCredential(trust: serverTrust)) } else { completionHandler(.performDefaultHandling, nil) } } } #endif ``` -------------------------------- ### Calculate Relative Cursor Position for Live2D Focus (TypeScript) Source: https://airi.moeru.ai/docs/en/blog/DevLog-2025.06.08 Calculates the cursor's position relative to the AIRI window. This is achieved by listening for mouse location and window frame events from Tauri and subtracting the window's origin from the cursor's absolute position. The result is stored in `live2dFocusAt`. ```typescript const live2dFocusAt = ref({ x: innerWidth / 2, y: innerHeight / 2 }) // initial position listen('tauri-app:window-click-through:mouse-location-and-window-frame', (event: { payload: [Point, WindowFrame] }) => { const [mouseLocation, windowFrame] = event.payload live2dFocusAt.value = { x: mouseLocation.x - windowFrame.origin.x, y: mouseLocation.y - windowFrame.origin.y, } }) ``` -------------------------------- ### Code Quality Checks Source: https://airi.moeru.ai/docs/en/docs/contributing Runs linting and TypeScript type checking to ensure code quality before committing changes. Can be executed via pnpm or the ni wrapper. ```shell pnpm lint && pnpm typecheck nr lint && nr typecheck ```