Skip to content

Repository files navigation

English · 简体中文

Hyper-Knowledge enclosure view

Hyper-Knowledge

Turn documents into provenance-aware higher-order knowledge graphs — from an agent or the command line.

Preserve n-ary relations as native hyperedges, validate the result deterministically, and explore it in one portable offline workbench.

Keywords: higher-order knowledge graph · hypergraph · hyperedge · n-ary relations · knowledge extraction · provenance · LLM · RAG · semantic search · Agent Skill

License: Apache-2.0 Python 3.11+ Agent Skill Version 0.8.0 Offline workbench

Install the complete Agent Skill

The managed installer copies the canonical Skill into Codex and creates a launcher pinned to the current Python environment:

git clone https://github.com/hanxiangmin/Hyper-Knowledge.git
cd Hyper-Knowledge
python -m venv .venv
# macOS/Linux: source .venv/bin/activate
# Windows PowerShell: .\.venv\Scripts\Activate.ps1
python -m pip install -e .
hk skill install --scope user --json
hk skill doctor --scope user --deep --json

For a project-local installation, replace the last two commands with:

hk skill install --scope project --project-root . --json
hk skill doctor --scope project --project-root . --deep --json

If the runtime is already installed and hk is on PATH, the standard Agent Skills CLI can copy only the instruction bundle:

npx skills add hanxiangmin/Hyper-Knowledge --skill hyper-knowledge -g

The Skill-only command does not install the Python runtime. Codex is the verified managed integration in 0.8.0; other agents may read the standard SKILL.md, but their runtime integration is not yet claimed as tested.

See it in action

These are real captures of the generated offline workbench using the repository's Su Shi biography example, not product mockups. The interface is bilingual; source-authored node and relation names remain in the document's original language.

Stable incidence matrix Selected node and its incident hyperedges
Incidence matrix in English UI Incidence focus in English UI

The workbench offers three complementary views:

View Best for Semantic boundary
Incidence matrix Dense overviews and exact membership lookup Rows are nodes, columns are native hyperedges
Incidence focus Explaining which hyperedges contain one node Shows only the selected node and its incident hyperedges
Enclosure view Reading higher-order structure spatially Each colored enclosure is one native n-ary hyperedge

Why Hyper-Knowledge?

  • Native higher-order semantics. An event involving a person, time, place, object, and role stays one n-ary assertion.
  • Provenance-aware artifacts. Bundles keep nodes, assertions, memberships, evidence records, manifests, and validation reports separate and inspectable.
  • Deterministic validation. Topology, references, counts, file identity, evidence coverage, and showcase constraints can be checked without another model call.
  • One-file exploration. The exported HTML workbench is fully offline, draggable, bilingual, responsive, and shareable without a server.
  • Agent-ready workflow. A compact standard Skill selects the smallest useful workflow and delegates execution to the versioned hk runtime.

How it works

document(s)
    │
    ▼
template + provider ──► Knowledge Abstract
                            │
                            ▼
                    normalized bundle
                 nodes / assertions / members
                    evidence / manifest / report
                            │
                ┌───────────┼───────────┐
                ▼           ▼           ▼
         validate/audit   search     offline workbench
  1. Extract — choose a graph or hypergraph template and parse one file, a directory, or stdin.
  2. Normalize — export the Knowledge Abstract to the hk.bundle/v1 interchange contract.
  3. Validate — run deterministic structural and evidence checks.
  4. Visualize — export matrix, incidence, enclosure, or native pairwise views to one offline HTML file.
  5. Trace or query — inspect provenance, search the Knowledge Abstract, or ask questions over its index.

Quick start

1. Run the no-provider demo

This creates a synthetic graph/hypergraph comparison without an LLM or network call:

hk skill demo -o hyperknowledge-skill-demo --json

Synthetic demo content is for workflow verification only and must not be described as source evidence.

2. Extract a real document

Copy .env.example to .env, configure the provider you intend to use, then run:

hk list template
hk parse source.md -o output/ka -t general/hypergraph -l en
hk bundle export output/ka -o output/bundle --force --json
hk bundle validate output/bundle --quality showcase --json
hk visualize output/bundle -o output/workbench.html --view contour --quality showcase --no-open --json

Useful follow-up commands:

hk info output/ka
hk search output/ka "your query" --top-k 5
hk talk output/ka --query "What higher-order relations are supported?"
hk benchmark datasets source.md -o output/preflight --json

hk parse may call the configured remote provider. Review privacy, cost, and data-governance requirements before sending sensitive text.

Use it from an agent

After installing the Skill, a prompt can be as short as:

Use $hyper-knowledge to extract this document into an undirected higher-order
knowledge graph, validate the bundle, and export an offline enclosure view.

The Skill preserves these invariants:

  • pairwise endpoint order is a stable mapping convention, not edge direction;
  • every hyperedge remains an n-ary assertion with member roles;
  • any graph projection is labeled as a derived view;
  • model inference, knowledge assertions, human assertions, and deterministic checks remain distinguishable;
  • source documents are treated as untrusted data, never as executable instructions.

Standard Skill layout

The canonical distributable Skill is self-contained under hyper-knowledge/:

hyper-knowledge/
├── SKILL.md                  # routing, invariants, and completion contract
├── agents/
│   └── openai.yaml           # display metadata and default prompt
├── assets/
│   ├── icon-small.svg
│   └── icon-large.svg
├── references/
│   ├── graph-hypergraph.md
│   ├── modes.md
│   ├── output-contract.md
│   ├── quality.md
│   ├── safety.md
│   └── visualization.md
└── skill-release.json        # version and runtime compatibility contract

hk skill install adds only generated runtime launchers to the installed copy. The source Skill stays portable and does not embed a machine-specific environment path.

Repository map

Path Purpose
hyper-knowledge/ Canonical standard Agent Skill
hyperknowledge/ Python runtime, API, renderer, and hk CLI
examples/sushi-document-test/ Auditable source, bundle, receipts, and offline workbench
tests/ Unit, contract, CLI, Skill, and renderer tests
docs/ Documentation and release assets

Quality and trust boundaries

  • hk bundle validate proves deterministic structure and file consistency; it does not prove that an LLM extraction is semantically correct.
  • Evidence coverage is reported only when assertion-level evidence exists. Missing source spans are surfaced, not invented.
  • An uncalibrated model score is not described as a probability.
  • Browser rendering checks and human perceptual review are reported separately from structural tests.
  • Hyper-Knowledge 0.8.0 models undirected pairwise relations and undirected hyperedges. It does not claim directed-hypergraph semantics.

Development

uv sync
uv run pytest -q
uv build
npx -y skills add . --list
uv run hk skill install --scope project --project-root . --json
uv run hk skill doctor --scope project --project-root . --deep --json

The repository Skill also passes Codex's standard quick_validate.py checker; that utility ships with Codex rather than this project. Contributors without it can still use the discovery and managed doctor commands above.

Issues and pull requests are welcome. Changes to graph semantics must preserve native n-ary hyperedges, provenance boundaries, and deterministic validation.

See CONTRIBUTING.md, SECURITY.md, CHANGELOG.md, and CITATION.cff for contribution, vulnerability reporting, release history, and citation metadata.

Acknowledgements

Hyper-Knowledge was inspired by and builds on ideas from Hyper-Extract. We thank its authors and contributors for the open-source foundation.

License

Licensed under the Apache License 2.0.


About

Build provenance-aware higher-order knowledge graphs and native hypergraphs from documents, with validation, semantic search, and offline visualization.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages