wasm
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "wasm":https://skillpi.com/zh/skills/deepskill-b1d8cb01edcb45e6bd2c08b5e9ad989dce84dd5b0d1f383a8ee62da19e3e1e9b。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/wasm-component-model-linker。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skillhub.cn
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 WASI Preview 2 组件模型、wasm-tools CLI 进行组件组合,并使用 wit-bindgen 从 WIT 接口定义生成主机/客人绑定,以编译和链接 WebAssembly 组件。
介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 来源文档未说明。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: wasm
description: >-
You are an expert in WebAssembly, the binary instruction format for
stack-based virtual machines. You help developers compile Rust, C, C++, Go,
and AssemblyScript to WASM for near-native performance in browsers, edge
functions, and serverless environments — building image/video processing,
games, crypto, AI inference, and compute-intensive tools that run 10-100x
faster than JavaScript.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Developer Tools
tags:
- webassembly
- performance
- browser
- rust
- c++
- portable
- edgeWebAssembly (WASM) — Near-Native Performance in the Browser
You are an expert in WebAssembly, the binary instruction format for stack-based virtual machines. You help developers compile Rust, C, C++, Go, and AssemblyScript to WASM for near-native performance in browsers, edge functions, and serverless environments — building image/video processing, games, crypto, AI inference, and compute-intensive tools that run 10-100x faster than JavaScript.
Core Capabilities
Rust → WASM
// src/lib.rs — Rust compiled to WASM
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn fibonacci(n: u32) -> u64 {
match n {
0 => 0,
1 => 1,
_ => {
let mut a: u64 = 0;
let mut b: u64 = 1;
for _ in 2..=n {
let tmp = a + b;
a = b;
b = tmp;
}
b
}
}
}
#[wasm_bindgen]
pub fn process_image(pixels: &[u8], width: u32, height: u32) -> Vec<u8> {
let mut output = Vec::with_capacity(pixels.len());
for chunk in pixels.chunks(4) {
let gray = (0.299 * chunk[0] as f32 + 0.587 * chunk[1] as f32 + 0.114 * chunk[2] as f32) as u8;
output.extend_from_slice(&[gray, gray, gray, chunk[3]]);
}
output
}
#[wasm_bindgen]
pub struct ImageProcessor {
width: u32,
height: u32,
data: Vec<u8>,
}
#[wasm_bindgen]
impl ImageProcessor {
#[wasm_bindgen(constructor)]
pub fn new(width: u32, height: u32) -> Self {
Self { width, height, data: vec![0; (width * height * 4) as usize] }
}
pub fn blur(&mut self, radius: u32) {
// Gaussian blur implementation — 50x faster than JS Canvas API
let kernel_size = (radius * 2 + 1) as usize;
// ... optimized blur using SIMD when available
}
pub fn data_ptr(&self) -> *const u8 { self.data.as_ptr() }
pub fn data_len(&self) -> usize { self.data.len() }
}
# Build with wasm-pack
cargo install wasm-pack
wasm-pack build --target web # For browser
wasm-pack build --target bundler # For webpack/vite
wasm-pack build --target nodejs # For Node.js
JavaScript Integration
// Use WASM from JavaScript
import init, { fibonacci, process_image, ImageProcessor } from "./pkg/my_wasm.js";
await init(); // Initialize WASM module
// Simple function call
const result = fibonacci(50); // ~0.001ms vs ~10ms in JS
// Image processing
const canvas = document.querySelector("canvas")!;
const ctx = canvas.getContext("2d")!;
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const processed = process_image(imageData.data, canvas.width, canvas.height);
const output = new ImageData(new Uint8ClampedArray(processed), canvas.width, canvas.height);
ctx.putImageData(output, 0, 0);
// Class instance
const processor = new ImageProcessor(1920, 1080);
processor.blur(5);
// Shared memory for zero-copy (advanced)
const memory = new WebAssembly.Memory({ initial: 256, maximum: 512, shared: true });
AssemblyScript (TypeScript-like)
// assembly/index.ts — TypeScript syntax → WASM
export function add(a: i32, b: i32): i32 {
return a + b;
}
export function sum(arr: Int32Array): i32 {
let total: i32 = 0;
for (let i = 0; i < arr.length; i++) {
total += unchecked(arr[i]); // Skip bounds check for performance
}
return total;
}
// Build: npx asc assembly/index.ts --outFile build/module.wasm --optimize
WASI (Server-Side WASM)
# Run WASM outside browsers with WASI
wasmtime run my_program.wasm # Bytecode Alliance runtime
wasmer run my_program.wasm # Wasmer runtime
# Edge computing (Cloudflare Workers, Fastly Compute)
# WASM modules run at the edge with near-native speed
Installation
# Rust → WASM
cargo install wasm-pack
rustup target add wasm32-unknown-unknown
# AssemblyScript
npm install -D assemblyscript
npx asc --init
# WASM runtimes
brew install wasmtime # Server-side WASM
brew install wasmer # Alternative runtime
Best Practices
- Use for compute — WASM excels at CPU-intensive tasks (image processing, crypto, parsing, physics); don't use for DOM manipulation
- Rust is the best fit — Rust has the most mature WASM toolchain (wasm-bindgen, wasm-pack); smallest binaries, no GC
- Minimize JS↔WASM calls — Cross-boundary calls have overhead; batch data and process in WASM, return results
- SharedArrayBuffer — Use shared memory for large data (images, audio); avoid copying between JS and WASM
- wasm-opt for size — Run
wasm-opt -O3on output; typically reduces binary size 10-30% - Streaming compilation — Use
WebAssembly.compileStreaming(fetch(...))for fastest loading; compiles while downloading - WASI for portability — Target WASI for server-side WASM; runs on Cloudflare, Fastly, Wasmtime, Wasmer
- Feature detection — Check
typeof WebAssembly === "object"before loading; fall back to JS for unsupported browsers
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 WebAssembly 开发工具链指导
- 覆盖 Rust、AssemblyScript 等多种语言编译方案
- 包含浏览器、服务端、边缘计算多场景应用
亮点
- 触发词精准覆盖 WebAssembly 生态核心工具
- description 清晰界定技能边界
亮点
- 文档结构完整,包含代码示例和最佳实践
- frontmatter 元数据规范完整
亮点
- 所有命令和工具来源明确可靠
- 覆盖主要异常场景和使用模式
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 142, 164, 165, 168, 169 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。