Metadata-Version: 2.5
Name: neurokeeper
Version: 0.12.1
Summary: Knowledge, kept kempt. Portable-core harness for agentic coding/knowledge work: deterministic engines + prompt templates + thin adapters.
Author: neurokeeper contributors
License: MIT
License-File: LICENSE
Keywords: agent,claude-code,config-as-code,knowledge-management,obsidian,vault
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Requires-Dist: pyyaml>=6.0
Provides-Extra: all
Requires-Dist: beautifulsoup4>=4.12; extra == 'all'
Requires-Dist: dateparser>=1.2; extra == 'all'
Requires-Dist: extract-msg>=0.48; extra == 'all'
Requires-Dist: lxml>=5.0; extra == 'all'
Requires-Dist: magika>=0.6; extra == 'all'
Requires-Dist: markitdown>=0.1; extra == 'all'
Requires-Dist: olefile>=0.47; extra == 'all'
Requires-Dist: openpyxl>=3.1; extra == 'all'
Requires-Dist: pillow>=10.0; extra == 'all'
Requires-Dist: pymupdf>=1.24; extra == 'all'
Requires-Dist: pytest>=8.0; extra == 'all'
Requires-Dist: python-docx>=1.1; extra == 'all'
Requires-Dist: python-pptx>=1.0; extra == 'all'
Requires-Dist: quotequail>=0.5; extra == 'all'
Requires-Dist: ruff>=0.6; extra == 'all'
Requires-Dist: xlrd>=2.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: ingest
Requires-Dist: beautifulsoup4>=4.12; extra == 'ingest'
Requires-Dist: dateparser>=1.2; extra == 'ingest'
Requires-Dist: extract-msg>=0.48; extra == 'ingest'
Requires-Dist: lxml>=5.0; extra == 'ingest'
Requires-Dist: magika>=0.6; extra == 'ingest'
Requires-Dist: markitdown>=0.1; extra == 'ingest'
Requires-Dist: olefile>=0.47; extra == 'ingest'
Requires-Dist: openpyxl>=3.1; extra == 'ingest'
Requires-Dist: pillow>=10.0; extra == 'ingest'
Requires-Dist: pymupdf>=1.24; extra == 'ingest'
Requires-Dist: python-docx>=1.1; extra == 'ingest'
Requires-Dist: python-pptx>=1.0; extra == 'ingest'
Requires-Dist: quotequail>=0.5; extra == 'ingest'
Requires-Dist: xlrd>=2.0; extra == 'ingest'
Provides-Extra: mail
Requires-Dist: beautifulsoup4>=4.12; extra == 'mail'
Requires-Dist: dateparser>=1.2; extra == 'mail'
Requires-Dist: extract-msg>=0.48; extra == 'mail'
Requires-Dist: magika>=0.6; extra == 'mail'
Requires-Dist: markitdown>=0.1; extra == 'mail'
Requires-Dist: quotequail>=0.5; extra == 'mail'
Provides-Extra: office
Requires-Dist: lxml>=5.0; extra == 'office'
Requires-Dist: olefile>=0.47; extra == 'office'
Requires-Dist: openpyxl>=3.1; extra == 'office'
Requires-Dist: python-docx>=1.1; extra == 'office'
Requires-Dist: python-pptx>=1.0; extra == 'office'
Requires-Dist: xlrd>=2.0; extra == 'office'
Provides-Extra: pdf
Requires-Dist: pillow>=10.0; extra == 'pdf'
Requires-Dist: pymupdf>=1.24; extra == 'pdf'
Description-Content-Type: text/markdown

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="assets/brand/neurokeeper-lockup-dark.svg">
    <img src="assets/brand/neurokeeper-lockup.svg" alt="neurokeeper" width="380">
  </picture>
</p>

<p align="center">
  <b>Knowledge, kept kempt.</b><br>
  Checks for a Markdown notes vault and an agent's memory: broken links, drifting tags, frontmatter
  that no longer fits its schema, and gates that quietly stopped running. Deterministic, local, and
  honest about what it did not check.
</p>

<p align="center">
  <a href="https://github.com/Wombat164/neurokeeper/actions/workflows/test.yml"><img src="https://github.com/Wombat164/neurokeeper/actions/workflows/test.yml/badge.svg" alt="CI"></a>
  <a href="https://github.com/Wombat164/neurokeeper/releases"><img src="https://img.shields.io/github/v/release/Wombat164/neurokeeper?color=10B981" alt="latest release"></a>
  <a href="LICENSE"><img src="https://img.shields.io/github/license/Wombat164/neurokeeper?color=334155" alt="License: MIT"></a>
  <img src="https://img.shields.io/badge/python-3.9%2B-334155" alt="Python 3.9 or newer">
</p>

<p align="center">
  <a href="#try-it">Try it</a> &middot;
  <a href="#what-it-catches">What it catches</a> &middot;
  <a href="#the-engines">Engines</a> &middot;
  <a href="#run-it-in-ci">CI gate</a> &middot;
  <a href="https://wombat164.github.io/neurokeeper/">Docs</a> &middot;
  <a href="CONTRIBUTING.md">Contributing</a>
</p>

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="assets/quickstart-dark.svg">
    <img src="assets/quickstart-light.svg" alt="Terminal: ref-audit reports 257 findings on an inherited 120-note collection, --write-baseline accepts 255 of them, and the next run reports adoption: 2 new, 255 baselined, 0 resolved" width="720">
  </picture>
</p>

An inherited vault never starts clean. neurokeeper reports what is wrong today, lets you accept that as a
baseline, and from then on tells you only what changed. Every engine runs offline, gives the same answer
for the same input, and never edits a note unless you ask it to.

## What it catches

| You notice | Engine |
|---|---|
| Links that point at notes which were renamed or never existed | `ref-audit` |
| Notes nothing links to, and notes that link nowhere | `ref-audit` |
| `#project`, `#projects` and `#Project` all in use | `tag-reconcile` |
| Frontmatter with values your schema does not allow, or fields it has never heard of | `frontmatter-lint` |
| A note you just wrote that existing notes should already link to | `semantic-gaps` |
| An email or ticket that the vault already has a note about | `correlate` |
| An agent memory index that grew past what the agent actually loads | `memory-consolidate` |
| A pre-commit hook that looks installed but can never run | `hooks-audit` |
| A gate or pattern that reports "clean" because it no longer fires at all | `gate-liveness`, `pattern-liveness` |
| A skill that tells an agent to use a script that is not there | `skill-refs-lint` |
| A missing optional library that turns a check into a silent empty result | `env-doctor` |

`neurokeeper doctor` runs every engine that applies and gives one report with an honest three-state
result: `ok`, `fail`, or `skipped`. Skipped is never shown as passed.

## Try it

1. Install the command-line tool (Python 3.9 or newer):
   ```
   pipx install neurokeeper
   ```
   Or run it once without installing: `uvx neurokeeper --list`. To track a tag straight from GitHub:
   `pipx install git+https://github.com/Wombat164/neurokeeper@v0.12.1`.
2. Look before anything is written. `init` reports how many notes it can see; a wrong root would
   otherwise report clean forever:
   ```
   neurokeeper init --collection /path/to/notes --dry-run
   ```
3. Write the config (never your notes) and run the full check:
   ```
   neurokeeper init --collection /path/to/notes
   neurokeeper doctor
   ```

Inheriting a messy vault? Run `neurokeeper ref-audit --write-baseline` once; later runs show only new
findings, as in the terminal above.

## Three ways to run it

The same engines back all three; there is one codebase and no fork.

**Claude Code plugin** (engines, skills and hooks):
```
/plugin marketplace add https://github.com/Wombat164/neurokeeper
/plugin install neurokeeper
```

**Command line**, anywhere Python runs: `neurokeeper <engine> [args]`, for example
`neurokeeper taxonomy-inventory --json`; `neurokeeper --list` shows every engine.

<a id="run-it-in-ci"></a>**CI gate**, as a pre-commit hook or a GitHub Action:
```yaml
# .pre-commit-config.yaml in your vault repository
repos:
  - repo: https://github.com/Wombat164/neurokeeper
    rev: v0.12.1
    hooks: [{ id: neurokeeper-doctor }]
```
```yaml
# a step in a GitHub workflow
- uses: Wombat164/neurokeeper@v0.12.1
  with: { vault-path: ".", engine: "doctor", strict: "false" }
```
A run fails on broken `.canvas` or `.base` references and on engine errors; advisory and skipped engines
never fail it ([ADR-0002](docs/adr-0002-doctor-exit-semantics.md)). Guide and a worked example vault:
[`docs/ci-adapters.md`](docs/ci-adapters.md), [`examples/vault/`](examples/vault).

## The engines

Everything is read-only and reports by default. Engines that change files do so only with `--apply`, refuse
while Obsidian has the vault open, and leave git as the audit trail.

**Links and structure**
- `ref-audit`: broken links, orphans, dead ends, broken `.canvas` and `.base` references, orphan media,
  notes whose names collide.
- `graph`: the link graph as data, with relatedness derived from the links people actually wrote.
- `semantic-gaps`: which existing notes should link to the one you just wrote.
- `correlate`: does the vault already know about this mail, ticket or transcript? Scored, with the
  evidence shown.

**Names, tags and frontmatter**
- `taxonomy-inventory`: what names, tags and frontmatter values are in use.
- `tag-reconcile`: tag families that should be one tag (you apply the merge, for example with Tag Wrangler).
- `frontmatter-lint` and `frontmatter-fix`: check notes against your schema; apply reviewed fixes.
- `set-note-type`: add a `note_type` derived from the folder.
- `name-reconcile`: kebab-case file names with every link updated.
- `register-lint`: identifiers used in the wrong category, as an alias, or unknown to your register.

**Agent memory**
- `memory-consolidate`: health of a file-based memory store: a score, orphans, broken links, the index size
  the agent really loads, and `--verify-links` to prove a compaction lost nothing.

**Checks that check themselves**
- `doctor`: runs everything applicable; one report, one honest roll-up.
- `selftest`: each engine must find every defect planted in its own bad fixture, and nothing in the clean one.
- `gate-liveness` and `pattern-liveness`: every gate must refuse a planted fault and every pattern must
  match a planted token; one that never fires is reported dead, not clean.
- `hooks-audit`: hooks that look installed and cannot run.
- `skill-refs-lint`: paths in skills and commands that no longer exist.
- `env-doctor` and `obsidian-preflight`: missing optional libraries; whether Obsidian is running, and what to
  run instead of a CLI call that would stall.

**Keeping things where they belong**
- `egress-gate` and `denylist-audit`: block listed terms at the moment content would leave the machine, and
  audit the list itself.
- `custody-audit`, `path-audit`, `vendor-audit`: is each declared file tracked and on a remote; what still
  points at a location you left; when an upstream file moves under a copy you keep on purpose.

Schema as code lives in your own config; [`config.example/`](config.example/) has a worked example.

## Bring your own engine

The core refuses domain-specific content, so a check that encodes your vocabulary or your team's policy
belongs in your repository, not here. Point `NEUROKEEPER_ENGINE_PATH` at it and your engine becomes a
first-class command, with the same dispatcher, the stable helpers in `neurokeeper.lib` (frontmatter
parsing and writing, atomic writes), the same exit contract, and an optional place in the `doctor` roll-up.
```bash
export NEUROKEEPER_ENGINE_PATH="/path/to/your-repo/engines"
neurokeeper acme-owner-audit --check      # your engine, your repository, your release cycle
```
A name that collides with a built-in is refused, and a configured directory that does not exist is an
error: reporting your engines as absent when they are only misconfigured is the failure this tool exists to
avoid. Contract and worked example:
[Extend with your own engine](https://wombat164.github.io/neurokeeper/how-to/extend-with-your-own-engine).

## How it is built

The logic lives in deterministic **engines** (`scripts/`, each with a `--json` contract) and
harness-neutral **prompt templates** (`prompts/`). A thin **adapter** binds them to a runtime: the Claude
Code plugin is one adapter; the plain CLI and CI are others. That is why one codebase serves all three, and
why the same engine can run beside a self-hosted model to save tokens. The keystone:
[`docs/pattern-portable-core-and-adapters.md`](docs/pattern-portable-core-and-adapters.md).

<details>
<summary>Repository layout</summary>

- `scripts/`: the engines; `_vault_lib.py` is the shared core, `_vault_guard.py` the Obsidian-running guard.
- `prompts/`: judgment templates. `skills/`: Claude Code adapter skills (thin, they defer to engines).
- `hooks/hooks.json`: Claude Code hooks. `.claude-plugin/plugin.json`: the plugin manifest.
- `config.example/`: example consumer config. This repository ships schemas and examples only, never real
  config or content.
- `docs/`: the pattern, decisions (ADRs), roadmap. `tools.lock`: runtime tool dependencies.

Each engine carries a metadata header (`@capability`, `@effect`, `@portability`, ...);
`scripts/registry-generate.py` builds the capability registry from them, so it is never hand-maintained.
</details>

<details>
<summary>Rebuild a whole machine (Linux, macOS, Windows)</summary>

`bootstrap/` rebuilds a multi-environment setup on a clean box: `tools-manifest.md` (per-OS install
sources), `bootstrap.sh` and `bootstrap.ps1` (idempotent installers; on Windows, the Everything file index is
opt-in with `-WithEverything`), `RUNBOOK.md` (auth, memory restore, Obsidian, a from-zero test) and
`repos.example.txt` (your private repo list stays gitignored).

Linux or macOS: `bash bootstrap/bootstrap.sh bootstrap/repos.txt ~/Projects`. Windows:
`pwsh -File bootstrap/bootstrap.ps1 -Root ~/Projects`. Then follow `RUNBOOK.md`.
</details>

<details>
<summary>Route cheap work to a self-hosted model (optional)</summary>

The `claude-cheap` wrapper sends mechanical, high-volume work (commit messages, summaries, extraction) to
your own `/v1/messages`-compatible endpoint for that one invocation; your default `claude` is untouched.
The billing trap to avoid, the task whitelist, serving recipes and the data-egress warning are in
[`docs/two-lane-model-handoff.md`](docs/two-lane-model-handoff.md).
</details>

## Related projects

If neurokeeper does not fit, one of these might:
- [claude-mnemo](https://github.com/jojoprison/claude-mnemo): Obsidian-vault memory for Claude Code with a
  lean index and a health audit; the closest neighbour on the memory side.
- [claude-memory-health](https://github.com/alexknowshtml/claude-memory-health) and
  [claude-memory-compiler](https://github.com/coleam00/claude-memory-compiler): Markdown memory audit and
  consolidation.
- [obsidian-mcp-server](https://github.com/cyanheads/obsidian-mcp-server): MCP tools for Obsidian.
- [Tag Wrangler](https://github.com/pjeby/tag-wrangler), [Linter](https://github.com/platers/obsidian-linter)
  and Smart Rename: the in-app layer neurokeeper defers to. The engines detect and propose; these apply.

What is different here is the deterministic engine suite behind one portable core. A source-checked survey
of the field: [`docs/competitive-landscape.md`](docs/competitive-landscape.md). Where it is heading, and
what is deliberately not planned: [`docs/roadmap.md`](docs/roadmap.md).

## Security and license

MIT, see [`LICENSE`](LICENSE). CI runs `gitleaks` on every push. Maintainers also run a private keyword scan
before publishing; its config lists the terms it looks for, so it stays out of the public tree and is not
needed to build, test or use the project. Optional extras and their licences, including two copyleft ones,
are listed in [`THIRD-PARTY-LICENSES.md`](THIRD-PARTY-LICENSES.md). Report issues as described in
[`SECURITY.md`](SECURITY.md).
