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 and source-code repositories. It uses agent-pdf-workspace for local extraction and OCR, and optional semantic code providers for evidence-bound architecture wikis. The core package contains no LLM, vision, embedding, or network client; an explicit code-generation command can invoke the user's installed OpenCode runtime.

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/block evidence or exact code revision/path/line/target 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

Install the semantic providers for source-code wikis with:

uv tool install 'agent-wiki-workspace[code]'

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

# Install the Wiki's OpenCode agent. Its name is <wiki-name>-curator.
wikiws agent install /absolute/path/to/wiki

Source-code architecture wikis

Code-wiki orchestration belongs to this package because it owns the Markdown layout, evidence contracts, staged changes, OpenCode agents, and quality evaluation. agent-codinglanguage-mapper remains the cross-language semantic provider; python-delphi-lsp adds Delphi-specific semantics and metrics.

Build a coherent wiki directly from a repository without copying source text into the wiki. The command recursively inventories supported source files, including tests, while excluding VCS, cache, generated, vendored, third-party, build, OpenCode, and agent-integration directories:

wikiws code build /absolute/path/to/repository \
  --wiki /absolute/path/to/wiki \
  --model openrouter/google/gemma-4-31b-it \
  --apply --json

Uncached semantic packets are analyzed with four concurrent OpenCode workers by default. Use --workers 1 for serial execution or select up to eight workers when the provider permits it. Apply builds create Agent Wiki Build Status.md immediately and update it after every completed packet, so multi-million-line repositories expose file/symbol counts and durable progress while the final pages are still being synthesized. Sources/inventory-in-progress.md appears after the deterministic inventory. After every validated packet, evidence-backed pages are refreshed under Entities/, Concepts/, and Syntheses/; their frontmatter and warning callout identify them as provisional. Successful packet checkpoints and provisional pages survive interruption. Global synthesis and the quality gate atomically replace them with final pages. A package-owned SHA-256 manifest prevents overwriting user notes or silently accepting manually changed provisional pages.

The wiki target may be absent, empty, or an existing managed agent wiki. Every source file and symbol remains in a deterministic coverage ledger outside the model context. The language mapper supplies bounded semantic packets and progressive focus/inspect/trace calls, so the model sees only useful working context without losing whole-codebase completeness. Each packet has its own evidence frontier: a model claim may cite only target IDs actually rendered in that packet or returned by a verified mapper tool call. Coverage and model context are therefore deliberately separate. Pages are organized by architecture, components, concepts, workflows, test-observed behavior, and significant entities. Small helpers are grouped; large or conceptually important helpers receive their own pages.

--apply is explicit. Without it, the command stages a dry-run report and writes no wiki pages. Run the same command after source changes to reuse unchanged packets and update/create/delete only managed pages. A no-change run performs zero model calls and zero page operations. Source IDs remain stable across revisions, and exact source revision/path/line/target evidence is verified before application.

Re-evaluate an applied full code wiki from its persisted mapper inventory, packet ledgers, current page contents, and page hashes with:

wikiws code evaluate /absolute/path/to/wiki \
  --changeset-id changeset-full-code-... \
  --minimum-score 90 --json

OpenCode model identifiers always use provider/model. For a custom provider named D, use --model D/gemma4. --vision-model configures the separate vision agent and is not the model selector for this code-wiki build.

The earlier anchor-based workflow remains available for intentionally bounded, entity-oriented wikis. Pass one important semantic anchor per detected language:

wikiws code generate /absolute/path/to/wiki \
  --source-id src-... \
  --anchor python=BaseEventLoop \
  --anchor rust=OpenOptions \
  --anchor csharp=LanguageParser \
  --anchor delphi=TSynLogVoid \
  --anchor cpp=getClangFormatStyle \
  --model openrouter/google/gemma-4-31b-it \
  --apply --json

Both builders deny raw file, shell, write, web, task, and generic LSP tools. They use agent-codinglanguage-mapper for every language and additionally use python-delphi-lsp for Delphi. Code evidence is rejected if the source changes, a path escapes the repository, a line is out of range, or the exact quote is absent. Evaluation happens before any page is applied, and the full builder requires complete deterministic file/symbol coverage plus resolvable navigation.

Provider skills, plugins, and agents are installed transactionally into the selected trusted OpenCode configuration directory, never into the repository. Generation rejects repositories that contain project-local OpenCode, Claude, or agent instruction controls because OpenCode could load those files before tool permissions take effect. The provider Python processes also run in isolated mode, and the OpenCode child receives only an allowlisted environment.

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

Install an existing managed Wiki as an OpenCode agent with the default command:

wikiws agent install /absolute/path/to/wiki

The selectable agent is named after the Wiki directory with only -curator appended, for example payments-platform-curator. The command does not pin a model in the generated curator or code builder. Select any available model in the OpenCode interface; otherwise OpenCode uses its configured default. For a Wiki with one registered source-code repository, the semantic mapper, Delphi provider, and model-selectable code builder are installed automatically.

Register or refresh all known Wikis, the router, shared vision agent, packaged skill, and native tools with the advanced command:

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 restricted to their bound tools, can be selected directly for auditable E2E queries, 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 for the separate vision agent. 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, source code/comments, 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.2.4.tar.gz (318.0 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.2.4-py3-none-any.whl (145.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_wiki_workspace-0.2.4.tar.gz
  • Upload date:
  • Size: 318.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for agent_wiki_workspace-0.2.4.tar.gz
Algorithm Hash digest
SHA256 3a763862da0510d4b8742bf1d6f80c6b928556992cd6ce4b4f3445b93e29354f
MD5 49af90db1b7008bc78de0f62acde284c
BLAKE2b-256 011b8cdaf882bbbd130c1a52ac0b7bcd3a366107ec699067f31a705c2650e13d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_wiki_workspace-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 217e3166c627e7205d473c79c868e55f2234f7598bab6e454483a1ac8a264ece
MD5 9b42ac5bc9646af30ce171dd29274fa3
BLAKE2b-256 bc1d14d97ae5bd0926bb9869f0aa1a11f2c5f9c37940a6cfcd69b0aafa9ab90f

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