> ## Documentation Index
> Fetch the complete documentation index at: https://harisfazillah.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Reference: openwiki_emulator.py

> Zero-binary, pure Python CLI tool emulating the OpenWiki documentation environment. Deep State of Mind framework. Deep State of Mind framework.

Zero-binary, pure Python CLI tool emulating the OpenWiki documentation environment.

## Description

The `openwiki_emulator.py` script replaces external Node.js binaries and cloud APIs with localised, offline execution. It compiles 9 markdown wiki pages, repairs Mermaid schemas, and exports an interactive graph visualiser.

## Script path

`tools/openwiki_emulator.py`

## CLI options

```bash theme={null}

# Initialise and compile the full OpenWiki workspace (default action)

uv run python tools/openwiki_emulator.py --init

# Retrieve recent Git changes and update context history

uv run python tools/openwiki_emulator.py --update

# Perform search against OpenWiki YAML metadata

uv run python tools/openwiki_emulator.py --search "ansible"

# Export a standalone offline HTML interactive knowledge graph

uv run python tools/openwiki_emulator.py --export-graph

```

## Inputs

* **Git status:** System porcelain variables used to determine modified workspace files.
* **Planned pages map:** Hardcoded schemas defining initial wiki content and layouts.

## Outputs

All workspace files created inside `./openwiki/`:

* **INSTRUCTIONS.md:** Standard CLI operating procedures and rules.
* **\_skeleton.md:** Ranking matrices and structural subsystems mapping.
* **graph.html:** Interactive standalone knowledge visualization layout.
* **quickstart.md / architecture / automation / memory:** Structured markdown documents.
* **.last-update.json:** Dynamic JSON execution tracker log.

## Dependencies

* **Python:** 3.12+ (standard `uv` environment).
* **pyyaml:** YAML data loading engine.

## Internal Python API

### `validate_mermaid_diagram(code)`

Validates Mermaid diagram layout syntax, bracket matches, and unescaped quotes.

* **Arguments:** `code` (raw string of the diagram block).
* **Returns:** `(bool, reason)` tuple representing valid status and description.

### `process_markdown_file(filepath)`

Scans a markdown file, detects corrupted or plain code fences, and repairs them.

* **Arguments:** `filepath` (absolute target file `pathlib.Path`).
* **Mechanism:** Degrades blocks in place with errors; heals corrected blocks back to active schemas.

***

*Deep State of Mind (DSOM) For My AI Protocol | Harisfazillah Jamel (LinuxMalaysia) | 2026-08-14*
*Standard: UK English | DBP-standard Bahasa Melayu Malaysia (Piawai) | GNU General Public License v3.0*


## Related topics

- [🛠️ HOWTO: Operating OpenWiki & Native Python Zero-Binary Emulator](/tools/howto-openwiki.md)
- [Explanation: OpenWiki & FastMCP Architecture](/explanation/openwiki-mcp-architecture.md)
- [Reference Material Index](/reference/index.md)
- [🌐 OpenWiki Integration Blueprint & Native Python Emulator Architecture](/governance/openwiki-integration-guide.md)
- [OpenWiki Knowledge Graph Compiler Skill](/skills/openwiki-compiler.md)
