SkillAtlasSkill 详情

alef

Rust in. Native bindings out.

审核状态:已审核Quality 72Security 52

复制安装命令

用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。

复制前请先查看来源、License 和安全提示。

项目 README

来源文件:README.md

抓取于 2026年7月29日

Xberg

Alef

א
Rust in. Native bindings out.

Alef is the polyglot binding generator behind the Xberg.dev ecosystem. It extracts a Rust API surface and emits language-native bindings, package scaffolding, type stubs, README files, API docs, e2e tests, and release metadata from one alef.toml.

Installation | Quick Start | Supported Targets | CLI Reference

Key Features

  • One source of truth - Configure a Rust workspace once and generate every enabled language target from it.
  • Language-native bindings - Emit host-language types, docs, errors, async wrappers, callbacks, and package files.
  • Multi-crate workspaces - Drive multiple independently published binding packages from a shared workspace config.
  • End-to-end fixtures - Generate cross-language test suites and registry-mode test apps from shared JSON fixtures.
  • Release-aware packaging - Sync versions, generate registry metadata, build artifacts, and validate publication state.
  • Configurable pipelines - Run setup, update, format, lint, test, clean, build, and publish commands per language.
  • Pluggable extension surface - Author domain-specific codegen logic via the Extension trait; ship as linked binaries, dynamic libraries, or template-only declarations.
  • Staleness checks - Cache inputs, embed generation hashes, and verify whether generated files are up to date.

Installation

Alef requires Rust 1.85 or newer.

cargo install alef --locked

If you use cargo-binstall, Alef also publishes binary-install metadata:

cargo binstall alef

Quick Start

Create or edit alef.toml in your Rust workspace:

[workspace]
languages = ["python", "node", "ffi", "go"]
alef_version = "0.24.12"

[[crates]]
name = "sample_core"
sources = ["src/lib.rs"]
version_from = "Cargo.toml"

Then generate the language packages:

alef generate --format
alef scaffold
alef readme
alef docs --output docs/reference
alef verify --exit-code

For a new project, Alef can create the initial config and first generated files:

alef init --lang python,node,ffi

For the full local generation pass, use:

alef all --format

Use --lang python,node to restrict commands to selected targets and --crate <name> to restrict commands to one configured crate.

Supported Targets

TargetBackend / package style
PythonPyO3 bindings with Python type stubs
TypeScript / Node.jsNAPI-RS native addon with .d.ts output
WebAssemblywasm-bindgen package for browser and JS runtimes
RubyMagnus native extension
PHPNative PHP extension
ElixirRustler NIF package
Rextendr package
Gocgo package over the generated C FFI layer
JavaJVM package over the generated native library
KotlinKotlin/JVM package over generated native bindings
Kotlin AndroidAndroid package with generated JNI shims
C#.NET package using P/Invoke
Dart / Flutterflutter_rust_bridge package
SwiftSwift package with Rust bridge support
ZigZig package over the generated C ABI
GleamGleam package backed by Rustler
C FFIC ABI, header, and shared-library glue
JNIRust JNI shim crate exercised by both kotlin_android (Android AAR) and host-JVM tests

Canonical language slugs are python, node, wasm, ruby, php, elixir, r, go, java, csharp, kotlin, kotlin_android, swift, dart, gleam, zig, ffi, and jni.

Configuration Model

Alef uses the current multi-crate schema:

  • [workspace] stores shared target languages, tool preferences, and pipeline defaults.
  • [[crates]] describes each Rust API surface that should become one or more published packages.
  • [crates.<language>] sections customize module names, package names, feature flags, output paths, field naming, dependency extras, and language-specific generation behavior.
  • [[crates.adapters]], trait bridge config, service API config, and e2e config opt into higher-level generated wrappers when a target supports them.

Generated binding files carry Alef hashes and are overwritten by generation commands. Scaffolded package files are generated once unless the command explicitly opts into overwrite behavior; generated README and API doc files are owned by alef readme and alef docs.

Extending Alef

Alef is opinionated about codegen and neutral about domain. The Extension trait lets you ship domain-specific generation logic (HTTP service APIs, plugin registries, custom bindings) without bloat in alef.

Linked Extension

Consumer crate implements alef::Extension, ships a thin CLI binary:

fn main() {
    alef::run_with_extensions(vec![Box::new(MyDomainExtension)])
}

Full type safety. Recommended for frameworks that generate an HTTP service API.

Dynamic Extension

Load a compiled .so/.dylib/.dll declaring a C-ABI factory function. Works when you can't ship a Rust binary.

[[extensions.dylib]]
path = "target/release/libmy_extension.dylib"
extern "C" fn alef_extension_factory() -> Box<dyn alef::Extension> {
    Box::new(MyExtension)
}

Template-only Extension

Declare [[extensions.template]] blocks in alef.toml pointing to Jinja templates. Alef's built-in TemplateExtension emits them — no Rust required.

The full extension walkthrough covers trait references and per-language emission patterns.

CLI Reference

CommandPurpose
alef initCreate alef.toml, generate initial bindings, and scaffold package files.
alef extractExtract Rust source into Alef IR JSON.
alef generateGenerate bindings, service API wrappers, public API wrappers, and type stubs.
alef stubsGenerate type stubs only.
alef scaffoldGenerate package manifests, native build files, and package scaffolding.
alef readmeGenerate per-language README files.
alef docsGenerate Markdown API reference pages.
alef setupInstall per-language development dependencies.
alef fmt / alef lintRun configured formatters, linters, and type checks.
alef testRun configured unit, integration, e2e, or coverage test commands.
alef buildBuild language bindings using native tools.
alef verifyCheck generated files and optional compile/lint state for CI.
alef diffShow what generation would change without writing files.
alef e2eInitialize, scaffold, validate, list, or generate local e2e suites.
alef test-appsGenerate and run standalone registry-mode test applications.
alef publishPrepare, build, package, and validate release artifacts.
alef allRun the full generation workflow in one command.

Run alef --help or alef <command> --help for the full option set.

Development

This repository uses task for common workflows:

task setup
task build
task test
task lint

The most useful targeted commands while working on Alef itself are:

cargo test <module_or_test_name>
cargo insta review
prek run --all-files

Part of Xberg.dev

  • Xberg — document intelligence: text, tables, metadata from 98+ formats with optional OCR.
  • Xberg Enterprise — managed extraction API with SDKs, dashboards, and observability.
  • crawlberg — web crawling and scraping with HTML→Markdown and headless-Chrome fallback.
  • html-to-markdown — fast, lossless HTML→Markdown engine.
  • liter-llm — universal LLM API client with native bindings for 14 languages and 143 providers.
  • tree-sitter-language-pack — tree-sitter grammars and code-intelligence primitives.
  • alef — the polyglot binding generator that produces every per-language binding across the 5 polyglot repos.
  • Discord — community, roadmap, and release discussion.

License

MIT - see LICENSE for details.

其他

高风险

  • 来源需自行核对维护者身份。
  • 包含脚本或命令调用,安装前请复核。
  • 可能需要外部 token、网络权限或第三方服务。
  • 存在潜在风险命令,请谨慎安装。
  • 扫描发现:3 条。

Codex — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/xberg-io/alef.git
  3. 将 "skills/alef" 文件夹复制到 Codex 的 skills 目录中。
  4. 重启 Codex 让新的 skill 生效。

Codex — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Codex 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Codex 让新的 skill 生效。

Claude Code — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/xberg-io/alef.git
  3. 将 "skills/alef" 文件夹复制到 Claude Code 的 skills 目录中。
  4. 重启 Claude Code 让新的 skill 生效。

Claude Code — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Claude Code 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Claude Code 让新的 skill 生效。

Cursor — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/xberg-io/alef.git
  3. 将 "skills/alef" 文件夹复制到 Cursor 的 skills 目录中。
  4. 重启 Cursor 让新的 skill 生效。

Cursor — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Cursor 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Cursor 让新的 skill 生效。

GitHub Copilot — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/xberg-io/alef.git
  3. 将 "skills/alef" 文件夹复制到 GitHub Copilot 的 skills 目录中。
  4. 重启 GitHub Copilot 让新的 skill 生效。

GitHub Copilot — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 GitHub Copilot 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 GitHub Copilot 让新的 skill 生效。

Windsurf — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/xberg-io/alef.git
  3. 将 "skills/alef" 文件夹复制到 Windsurf 的 skills 目录中。
  4. 重启 Windsurf 让新的 skill 生效。

Windsurf — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Windsurf 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Windsurf 让新的 skill 生效。
查看 SKILL.md 原文
name: alef
description: >-
  Use Alef correctly for Rust-to-polyglot binding generation. Trigger when
  configuring alef.toml, generating bindings, READMEs, API/CLI/MCP docs,
  llms.txt, agent skills, e2e suites, or debugging stale/missing generated
  output in Alef-powered repositories. Covers the safe command sequence,
  config ownership, generated-output rules, snippet validation, downstream
  smoke testing, and Alef development workflow.
license: MIT
metadata:
  author: xberg-io
  version: "1.0"
  repository: https://github.com/xberg-io/alef

Alef

Alef extracts a Rust public API surface and generates language-native bindings, package scaffolding, type stubs, READMEs, docs, e2e tests, and release metadata from alef.toml.

Use this skill when working in Alef itself or in a downstream repo that uses Alef.

Core Rules

  • Treat Rust source plus alef.toml as the source of truth.
  • Read the local alef.toml before proposing config or generation changes.
  • Do not hand-edit Alef-managed generated files except when adopting an existing file into Alef management.
  • Preserve user changes in dirty worktrees. Stage and commit only the requested scope.
  • Prefer narrow commands while iterating, then run the broader verification command before committing.
  • For user-visible Alef behavior changes, update CHANGELOG.md.

Standard Consumer Workflow

From a repo that uses Alef:

alef generate --format
alef scaffold
alef readme
alef docs
alef verify --exit-code

Use the combined command when a full refresh is expected:

alef all --format

Use filters to keep iteration small:

alef generate --lang python,node
alef docs --output docs/reference
alef test --lang python
alef verify --exit-code

When testing an unreleased local Alef from a sibling repo, run the binary through Cargo instead of using the installed version:

cargo run -q --manifest-path ../alef/Cargo.toml -- docs
cargo run -q --manifest-path ../alef/Cargo.toml -- all --format

Config Model

Current Alef configs use:

  • [workspace] for shared languages, tools, DTO defaults, docs defaults, and pipeline defaults.
  • [[crates]] for each generated package/API surface.
  • [crates.<language>] or [workspace.<language>] for target-specific output, package names, feature flags, excludes, and stubs.
  • source_crates when a facade crate re-exports API from multiple Rust crates.
  • features when cfg-gated public fields/types must be considered present.

Use include for small curated APIs. Use exclude for large APIs where most public items should bind except known internal, generic, trait, or unsupported items.

Generated Docs, llms.txt, and Skills

Alef can generate docs in this order:

  1. API reference docs from extracted Rust API.
  2. CLI reference docs from configured Clap sources.
  3. MCP reference docs from configured rmcp-style sources.
  4. Snippet index and configured snippet validation.
  5. Template-rendered llms.txt.
  6. Template-rendered grouped skills.

Important rules:

  • llms.txt and skills are template-owned. Missing templates are hard errors.
  • Alef should not invent full prose for llms.txt or skills.
  • Existing unmanaged outputs require explicit adopt_existing = true.
  • Generated Markdown keeps frontmatter first, then Alef's managed hash marker.
  • Warn only for actionable skips: missing configured sources, configured extractors discovering nothing, missing configured snippet dirs, or unavailable snippet toolchains.

Common docs config shape:

[workspace.docs]
reference_output = "docs/reference"

[workspace.docs.cli]
sources = ["crates/my-cli/src/main.rs"]

[workspace.docs.mcp]
sources = ["crates/my-lib/src/mcp/server.rs"]

[workspace.docs.llms]
template = "templates/docs/llms.txt.jinja"
output = "docs/llms.txt"
adopt_existing = true

[workspace.docs.skills]
template_dir = "templates/docs/skills"
outputs = [".codex/skills", ".agents/skills", ".claude/skills", ".github/skills"]
adopt_existing = true

[workspace.docs.snippets]
dirs = ["docs/snippets"]
docs_dirs = ["docs"]
required_languages = ["python", "rust"]
validation_level = "syntax"

Skill templates default to grouped api, cli, and mcp skills:

templates/docs/skills/
├── api/SKILL.md.jinja
├── cli/SKILL.md.jinja
└── mcp/SKILL.md.jinja

Snippets

Use snippets as maintained examples, not generated filler. Configure validation instead of silently trusting examples:

  • dirs: snippet roots.
  • docs_dirs: docs/template roots to scan for includes.
  • required_languages: language variants every grouped snippet should have.
  • validation_level: syntax, typecheck, compile, or run.
  • include_base_paths: paths matching MkDocs snippet include roots.

Unreferenced snippets should normally warn, not fail. Missing references, missing required language variants, unknown languages, and skip annotations without reasons should fail.

Debugging

Missing type or function:

alef extract -o /tmp/api.json
jq '.types | keys' /tmp/api.json

Then check:

  • Is the source file listed in sources or source_crates?
  • Is the item public and reachable from the configured source?
  • Is it excluded in config or with an Alef attribute?
  • Does it depend on an unsupported generic, trait object, or external type?
  • Does the target language need an FFI layer (ffi) or explicit type mapping?

Stale output:

alef verify --exit-code
alef diff
alef generate --clean --format

Cache issues:

rm -rf .alef
alef generate --clean --format

Docs generation issues:

  • Confirm template paths are relative to the workspace root.
  • Confirm configured CLI/MCP source paths exist.
  • Confirm generated outputs have Alef headers or adopt_existing = true.
  • Use -v/RUST_LOG when a warning is expected but not visible.

Working on Alef Itself

In the Alef repo, prefer focused checks while iterating:

cargo fmt
cargo check -q
cargo test -q docs:: -- --nocapture
cargo test -q <module_or_test_name>

Before committing behavior changes, run the highest-signal relevant tests. For docs/template work, also smoke test downstream repos with the local binary:

cargo run -q --manifest-path ../alef/Cargo.toml -- docs
git diff --check

Use the sibling repos that exercise Alef broadly:

  • ../crawlberg
  • ../html-to-markdown
  • ../liter-llm
  • ../tree-sitter-language-pack

Do not include ../xberg unless explicitly asked.

Release Notes and Commits

  • Update CHANGELOG.md under [Unreleased] for user-visible changes.
  • Keep release commits separate from feature/fix commits.
  • Do not add AI attribution to commits, tags, or release notes.
  • Use the existing release procedure skill when cutting a version.

发现问题?提交给管理员复核

评分:

评论 (0)

暂无评论,成为第一个评论者吧!