Skip to main content

Contract-driven Markdown knowledge bases for PDF-aware agents

Project description

agent-wiki-workspace

agent-wiki-workspace builds persistent, searchable Markdown knowledge bases from local PDFs. It uses agent-pdf-workspace for local extraction and OCR, keeps the complete source workspace, and exposes strict JSON contracts to external agents. The package itself contains no LLM, vision, embedding, or network client.

What it creates

An existing Markdown or Obsidian vault can be adopted in place, or a new empty directory can be initialized:

wiki/
├── Sources/ Concepts/ Entities/ Syntheses/
├── raw/<source-id>/                  # complete agent-pdf-workspace output
└── .agent-wiki/
    ├── manifest.json
    ├── profile.{json,md}
    ├── jobs/{curation,query,visual}/
    ├── changesets/
    └── cache/search.sqlite

Existing notes, .obsidian/, AGENTS.md, and symlinks are not rewritten or followed. Curated claims retain PDF page and block or bounding-box evidence. Agent changes are staged first and are applied only by an explicit host/user action.

Install

Python 3.11 through 3.14 is supported. A permanent tool environment is recommended because the generated OpenCode tool records its exact Python virtual-environment launcher:

uv tool install agent-wiki-workspace
wikiws --help

For repository development, use the pinned pyenv version and lockfile:

pyenv install -s 3.11.14
uv sync --frozen --group dev

Quick start

# A new wiki must be new or empty.
wikiws init /absolute/path/to/wiki --mode create --json

# Existing Markdown/Obsidian content is adopted without modifying existing files.
wikiws init /absolute/path/to/vault --mode adopt --json

# Extraction and OCR are local. The original PDF stays under raw/<source-id>/.
wikiws source add /absolute/path/to/wiki report.pdf --ocr auto --language deu+eng --json

# Explore locally.
wikiws search /absolute/path/to/wiki "specific phrase" --json
wikiws read /absolute/path/to/wiki --note "Sources/report.md" --json

# Agent-authored changes remain pending until explicitly approved.
wikiws curate prepare /absolute/path/to/wiki --source-id src-... --json
wikiws curate submit /absolute/path/to/wiki --input changeset.json --json
wikiws changes apply /absolute/path/to/wiki --changeset-id chg-... --json

wikiws lint /absolute/path/to/wiki --json
wikiws verify /absolute/path/to/wiki --json

Machine-readable mode writes JSON only to stdout and diagnostics to stderr. Exit codes are 0 (success), 2 (input/contract error), 3 (incomplete state), 4 (resource limit), and 5 (integrity/security failure).

OpenCode integration

Register one router, one curator per wiki, a shared vision agent, the packaged skill, and native tools with:

wikiws opencode sync

OpenCode also receives the primary agent agent-wiki-manager. Select it and ask it to initialize a Wiki at an absolute path; the directory must be new or empty. The manager can only call the package's create tool. It cannot adopt existing content, use shell or web tools, or apply curated changes.

The router and shared vision agent are installed as primary agents; per-Wiki curators are registered as restricted subagents and communicate through persisted versioned contracts.

The command discovers the configuration through OPENCODE_CONFIG_DIR or opencode debug paths. It never edits opencode.json and refuses collisions with files it does not own. Interactive sync asks which vision-capable provider/model to use. The default is openrouter/google/gemma-4-31b-it; automation can choose any valid OpenCode model identifier:

wikiws opencode sync --vision-model openrouter/google/gemma-4-31b-it --json
wikiws doctor --json

The generated TypeScript tool starts exactly [absolute-venv-python, "-m", "agent_wiki_workspace", ...] without a shell or PATH lookup. Running sync again updates that binding after moving or reinstalling the environment.

Visual jobs remain pending if the selected agent/model cannot inspect images. Text curation and search continue with visual_coverage: pending; no description is fabricated. A capable external agent reads only a registered crop, then persists a matching VisualResult. Whether an image may be sent to a remote model is the calling system's privacy decision.

Python API

from agent_wiki_workspace import KnowledgeBase, KnowledgeRegistry

kb = KnowledgeBase.init("/absolute/path/to/wiki", mode="create")
source = kb.add_pdf("report.pdf", ocr="auto", languages=("deu", "eng"))
job = kb.prepare_curation(source.source_id)
hits = kb.search("specific phrase")

registry = KnowledgeRegistry.open()
registry.register(kb)
registry.install_opencode(vision_model="openrouter/google/gemma-4-31b-it")

All public agent contracts are Pydantic models using schema 1.0, reject unknown fields, and fail closed on wrong wiki/job IDs, expired jobs, unsafe paths, stale updates, or unverifiable evidence. A source changeset copies job.job_id and cites every claim with a block_id or page-bounded bbox from the PDF layout sidecar. Block quotes are normalized and checked against block text.

Trust boundary

PDF text, OCR, Markdown, metadata, links, attachments, QR codes, and images are untrusted content. They are never executed or fetched. Package-generated agents deny web and shell tools and receive only role-specific wiki tools. PDF passwords are accepted through Python parameters or stdin and are never persisted.

See the release procedure and verification status for reproducible builds, critical coverage, neutral clean-environment evidence, and the explicitly networked OpenRouter/OpenCode multi-wiki release gate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_wiki_workspace-0.1.1.tar.gz (169.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_wiki_workspace-0.1.1-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

Details for the file agent_wiki_workspace-0.1.1.tar.gz.

File metadata

File hashes

Hashes for agent_wiki_workspace-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a68a4faf5e95bc2e23c0a48bd25fd3529c13aa4d4f41311c0deeed82999bc38a
MD5 f411dc700e993a347306700e9587785e
BLAKE2b-256 0c9e70d5f3ba3399334a1c5f15dd71539af16722359fa0dbfcbdb0be50ceff43

See more details on using hashes here.

File details

Details for the file agent_wiki_workspace-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_wiki_workspace-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eedf531a7f7c0652d0c7e42e49474f837f6748e603df6db06d3dbd199ce6d012
MD5 3058cd567d724d170a170fee09a6b044
BLAKE2b-256 c9ded94f783c036767a140f10278bd5bf05a6301453472b6de039f8516a27097

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page