← 返回 Skills 市场
highnoonoffice

Library of Babel

作者 highnoonoffice · GitHub ↗ · v0.1.1 · MIT-0
cross-platform ⚠ suspicious
74
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install library-of-babel
功能描述
Bidirectional mathematical engine for Borges' Library of Babel. Finds the permanent hexagon address of any text, reads any page at any coordinate, and scores...
使用说明 (SKILL.md)

Library of Babel

A bidirectional mathematical engine for Borges' infinite library.

No database. No storage. No randomness. Same input always produces identical output — across machines, across time.


What It Does

Forward: Paste any text → get its permanent address (Hexagon, Wall, Shelf, Volume).

Reverse: Give coordinates → get the 3,200-character page that has always lived there.

The Library doesn't generate text. It reveals what was always there.


Usage

Forward lookup — find where your text lives

from babel_core import format_locate

print(format_locate("call me ishmael"))

Output:

📍 Hexagon 936,177,732,035,491,926 · Wall 3 · Shelf 4 · Volume 21
(Global index: 936177732...)

This text has always existed here. It is not generated — it is found.

Reverse lookup — read a page at any coordinate

from babel_core import format_read_page

print(format_read_page(hexagon=1, wall=1, shelf=1, volume=1))

Output:

📖 Hexagon 1 · Wall 1 · Shelf 1 · Volume 1

sw,quamqysyjnki.eog,u,gl.b.u uuejbadqcfwmbegfeljp.toqwpq... (3200 chars total)

Entropy analysis — how noise-like is a page?

from babel_core import index_to_page, shannon_entropy, space_frequency, classify_page

page = index_to_page(12345)
h = shannon_entropy(page)
sp = space_frequency(page)
tag = classify_page(h, sp)
print(f"H={h:.2f} bits | space={sp:.1f}% | {tag}")

Shannon entropy thresholds (theoretical max for 29-char alphabet: log₂(29) ≈ 4.86 bits):

  • 🟢 coherent — H \x3C 3.8 and space > 14% (almost never random — that's the point)
  • 🟡 interesting — H 3.8–4.5 or space 6–14%
  • 🔴 noise — H > 4.5 or space \x3C 6%

The Codex

codex.json ships with 7 pre-mapped passages from literature and culture. Zero tokens to browse — it's a static JSON read. The coordinates are permanent and independently verifiable.

from demo import show_codex, add_to_codex

# Display all pre-mapped passages
show_codex()

# Add your own — coordinates computed and persisted immediately
add_to_codex("the medium is the message", "Understanding Media — Marshall McLuhan")

Pre-mapped passages:

  • "call me ishmael" — Moby Dick
  • "it was a bright cold day in april..." — 1984
  • "the library of babel" — Borges
  • "in the beginning god created the heavens and the earth" — Genesis 1:1
  • "to be or not to be that is the question" — Hamlet
  • "it was the best of times it was the worst of times" — A Tale of Two Cities
  • "attention is a currency" — High Noon Office

Three Demo Scripts

Run all four demos at once:

python3 demo.py

Or call individually:

from demo import locate, read_page_demo, entropy_heatmap, show_codex, add_to_codex

# Demo 1: Locate any text
locate("the library of babel")

# Demo 2: Read a page at coordinates
read_page_demo(hexagon=1, wall=1, shelf=1, volume=1)

# Demo 3: Entropy heatmap — 5 random coordinates, ranked by Shannon entropy + space frequency
entropy_heatmap(n=5)

# Demo 4: Codex — browse pre-mapped passages
show_codex()

The Math

Alphabet: abcdefghijklmnopqrstuvwxyz ,. — 29 characters (Borges' 25-char set extended to full Latin alphabet)

Forward (text → index): Interpret the filtered character sequence as a base-29 integer.

Coordinates:

Volume  = index % 32
Shelf   = (index // 32) % 5
Wall    = (index // 160) % 4
Hexagon = index // 640

Page generation: SHA-256 counter-mode hash expansion. SHA256(gi_bytes || chunk_id) repeated to fill 3,200 bytes, each mapped to the alphabet via byte % 29. Deterministic, chaotic, sub-millisecond.

Note on the LCG approach: A Linear Congruential Generator with a=30, m=29^3200 maps small indices (e.g. 640) to tiny values like 19201, which decode as 3,197 leading 'a' characters when expanded to 3,200 base-29 digits. Hash expansion solves the distribution problem correctly.


Files

library-of-babel/
  SKILL.md          — This file
  babel_core.py     — Core math engine
  demo.py           — Four runnable demonstrations + codex functions
  codex.json        — Pre-mapped passages (add your own with add_to_codex())
  references/
    spec.md         — Full technical specification

Setup

No dependencies beyond Python 3 standard library (hashlib, math, collections, json).

cd library-of-babel
python3 demo.py
安全使用建议
The package appears to implement exactly what it claims (a deterministic Library-of-Babel engine) and has no network calls or secret requirements — that is good. Two small but important caveats: (1) despite the README's blanket statement of “No storage,” the demo function add_to_codex() will append user-provided entries to codex.json in the skill folder (it persists data locally); (2) despite saying “No randomness,” the demo entropy heatmap uses a PRNG to pick demo coordinates (the core page-generation math remains deterministic). If you plan to install/run this skill: run it in a sandbox or inspect/backup codex.json first, avoid running it with elevated privileges, and be comfortable that the skill will write to its local codex.json file. If you need the skill to be read-only, do not call add_to_codex() or make codex.json immutable. Finally, the package source and homepage are unknown — if provenance is important, try to verify the author or obtain the code from a trusted source before trusting it in production.
功能分析
Type: OpenClaw Skill Name: library-of-babel Version: 0.1.1 The skill bundle implements a deterministic mathematical engine for Borges' 'Library of Babel' using standard Python libraries (hashlib, math, json). The code is well-documented, lacks external dependencies, and contains no evidence of data exfiltration, malicious execution, or prompt injection. File operations are restricted to reading and updating its own local 'codex.json' file.
能力评估
Purpose & Capability
The name/description (find addresses, read pages, compute entropy) align with the included Python code (babel_core.py, demo.py). However SKILL.md repeatedly claims “No database. No storage. No randomness,” while the package provides demo code that (a) uses random.Random to pick demo coordinates and (b) includes add_to_codex() which writes user entries to codex.json. These behaviors are reasonable for demos but contradict the 'no storage/no randomness' claim in the README.
Instruction Scope
The runtime instructions and code operate only on local files and pure-Python math operations: they read/write codex.json and call deterministic hash functions. The skill does not reference environment variables, network endpoints, or system paths outside its own directory. The only file write is codex.json via add_to_codex(), which is within the advertised codex feature.
Install Mechanism
No install spec and no external downloads; this is an instruction + source bundle that relies only on the Python standard library (hashlib, json, etc.). No network fetch or archive extraction is present.
Credentials
The skill requests no environment variables or external credentials. All required resources are local files included in the bundle (codex.json). No unexpected secrets or unrelated credentials are requested.
Persistence & Privilege
always:false and the skill doesn't request elevated/system-wide privileges. It does persist user additions to codex.json in its directory (add_to_codex writes JSON). This is limited in scope, but it does change local disk state — users should be aware of this persistent write.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install library-of-babel
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /library-of-babel 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.1
Fix SKILL.md frontmatter to spec, update spec.md to reflect SHA-256 implementation, fix demo.py import shadow bug, remove __pycache__ from tracking
元数据
Slug library-of-babel
版本 0.1.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Library of Babel 是什么?

Bidirectional mathematical engine for Borges' Library of Babel. Finds the permanent hexagon address of any text, reads any page at any coordinate, and scores... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 74 次。

如何安装 Library of Babel?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install library-of-babel」即可一键安装,无需额外配置。

Library of Babel 是免费的吗?

是的,Library of Babel 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Library of Babel 支持哪些平台?

Library of Babel 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Library of Babel?

由 highnoonoffice(@highnoonoffice)开发并维护,当前版本 v0.1.1。

💬 留言讨论