Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Analects

**A research knowledge graph where every value cites a source.**
**An open research record: what you and your agents find, kept per entity in the source's own words, with every change on file.**

Analects is for research that has to stand up: who is building which data centre, which
company is behind it, how a representative voted, what a register says now and
what it said last month. You and the agents working for you record what you find
as claims about entities. Every claim cites an event — a document, a locator and
the exact words, checked against a saved copy of the page. Nothing is written from
memory, and nothing is overwritten: a newer value supersedes an older one, or
contests it, and the history stays readable.
[Docs](https://kindtechuk.github.io/analects/) · [Questions and ideas](https://github.com/KindTechUK/uk-open-data/discussions) · [Contribute](CONTRIBUTING.md)

It runs as a CLI and as an MCP server, so it works with Claude Code, Claude
Desktop, claude.ai (through a hosted peer) and any MCP client.
```text
$ analects check sources/apatura/ravenscraig-the-project.txt --source https://consult.apatura.energy/ravenscraig/the-project ...
check https://consult.apatura.energy/ravenscraig/the-project [management_statement] refused 1 new 2

refused — not staged — the document does not support this
Ravenscraig capex=GBP 3.9bn
this quote is not in the document. Re-read it and copy the exact words, or drop the claim.
```

From [`examples/uk-data-centres.sh`](examples/uk-data-centres.sh), which runs on saved pages with no network. Every headline reports a £3.9bn investment in the campus. The developer's own page does not say it, so Analects refuses to record it from that page.

## Try it

## Install
You need [uv](https://docs.astral.sh/uv/) and Python 3.11 or newer.

```bash
uv tool install "git+https://github.com/KindTechUK/analects"
Expand All @@ -22,7 +26,21 @@ analects schema test
```

Then connect your agent — `claude mcp add analects -- analects mcp` for Claude Code — and read
[your first research run](docs/getting-started/first-research-run.md).
[your first research run](docs/getting-started/first-research-run.md). To watch it work first, run
the example above from a clone: `uv sync`, then `bash examples/uk-data-centres.sh`.

## About

Analects is for research that has to stand up: who is building which data centre, which
company is behind it, how a representative voted, what a register says now and
what it said last month. You and the agents working for you record what you find
as claims about entities. Every claim cites an event — a document, a locator and
the exact words, checked against a saved copy of the page. Nothing is written from
memory, and nothing is overwritten: a newer value supersedes an older one, or
contests it, and the history stays readable.

It runs as a CLI and as an MCP server, so it works with Claude Code, Claude
Desktop, claude.ai (through a hosted peer) and any MCP client.

## What it does

Expand Down
6 changes: 5 additions & 1 deletion docs/getting-started/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ It says where each thing is:

| What | Where | Change it with |
| --- | --- | --- |
| the graph (`graph.db`, SQLite) | the current folder, or the nearest one above it that has a `graph.db` | `--db`, `$ANALECTS_DB` |
| the graph (`graph.db`, SQLite) | the nearest folder, starting at the current one, that has a `packs/` folder or a `graph.db`; the current folder if none does | `--db`, `$ANALECTS_DB` |
| the config (`analects.yaml`) | `~/.analects/analects.yaml` | `$ANALECTS_CONFIG` |
| the packs | the ones Analects ships with, plus a project's own `packs/` folder (`analects schema new`) | `$ANALECTS_PACKS` |

Any folder called `packs/` counts, even one that holds no Analects packs, so the
graph can land in a folder above the one you are in. `analects init` prints the path
it chose: check it.

Analects was called kg. An old `~/.kg/kg.yaml`, the `kg` command and any `$KG_…`
setting still work; a `$ANALECTS_…` setting wins over its `$KG_…` twin
([D69](../decisions/D69-kg-is-renamed-analects-and-the-old-names-keep-working.md)).
Expand Down
44 changes: 31 additions & 13 deletions docs/getting-started/first-research-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,37 @@
This walks the loop on captured pages, with no network: the same investigation
the [examples](../../examples/README.md) run end to end.

The captured pages are in the repository. Run the steps from the top folder of a
clone:

```bash
git clone https://github.com/KindTechUK/analects && cd analects
```

## 1. A claim, from a developer's own page

A developer's consultation page says what it will build. `analects check` reads the
page's text and the facts you extracted from it, checks every quote is on the
page, and says what is new, what contradicts what you hold, and what cannot be
matched — writing nothing:
matched — writing nothing. Here the page is Apatura's page on Ravenscraig, and the
facts are in `examples/data/ravenscraig-mentions.json`:

```bash
analects check page.txt --source https://example.org/the-project \
--type management_statement --mentions mentions.json --ops-out ops.json
analects write --ops ops.json # stage them
analects review # what is waiting, and why
analects merge --all # under `confirm`, after you have looked
analects check tests/golden/sources/apatura/ravenscraig-the-project.txt \
--source https://consult.apatura.energy/ravenscraig/the-project \
--type management_statement --published-at 2026-09-22 \
--mentions examples/data/ravenscraig-mentions.json --ops-out ops.json
analects write --ops ops.json # stage them
analects review # what is waiting, and why
analects merge --all --confirm entity # after you have looked
```

A figure that is reported everywhere but is not on this page is refused by name:
the page is the evidence, not the headline.

Under `confirm`, `merge --all` holds a new entity for you. `--confirm entity` says
you have read it.

## 2. Ask the graph

```bash
Expand All @@ -33,21 +46,26 @@ analects get "Ravenscraig" --as-of 2026-01-01
## 3. Corroborate from a register

```bash
analects import companies-house basic-subset.csv
analects import neso-tec tec.json
analects brief "Ravenscraig" # the grid queue now corroborates, or contests
analects import companies-house tests/golden/sources/companies-house/basic-subset.csv
analects import neso-tec tests/golden/sources/neso/tec-apatura.json
analects import neso-tec tests/golden/sources/neso/tec-newarthill.json
analects query --type interconnection_request --where "customer ~ APATURA"
```

A second, independent source raises confidence; a different value makes the
property contested, and both stay visible.
The grid queue holds eighteen of Apatura's connections, and none is called
Ravenscraig. A second, independent source raises confidence; a different value
makes the property contested, and both stay visible.

## 4. Leave it better

```bash
analects truth "Ravenscraig" --set "Two to six sentences: what it is, what changed, what is unknown."
analects defer "a fact you could not place" --reason no_site
analects truth "Ravenscraig" --set "An announced 550MW AI data campus. The only source is the developer's own page, and the widely reported £3.9bn is not on it. No connection in the grid queue is tied to it yet."
analects defer "Which grid connection is Ravenscraig's? The PSC register would settle it." \
--reason missing_entity --entity Ravenscraig
analects merge --all --confirm truth # you wrote it: land it
```

A truth is two to six sentences: what it is, what changed, what is unknown.
Next time anyone — you or an agent — runs `analects brief`, it starts from here.

## Run the full examples
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ votes, statements) — ship with it. Check they load:

```bash
analects schema test
# 3 packs load; 12 entity types; 17 fixtures well-formed
# 3 packs load; 12 entity types; 20 fixtures well-formed
```

## Optional extras
Expand Down
11 changes: 9 additions & 2 deletions examples/_lib.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Shared plumbing for the demos. Each demo builds a fresh graph in a temporary
# directory from the sources captured in tests/golden/sources/, so running one
# never touches your own graph.db and never makes a network request.
# never touches your own graph.db and never makes a network request. The
# directory is removed when the demo ends, unless ANALECTS_DEMO_DIR names one
# to keep.

set -u
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SOURCES="$ROOT/tests/golden/sources"
DEMOS="$ROOT/examples"
ANALECTS="${ANALECTS:-uv run --project $ROOT --quiet analects}"

WORK="${ANALECTS_DEMO_DIR:-$(mktemp -d)}"
if [ -n "${ANALECTS_DEMO_DIR:-}" ]; then
WORK="$ANALECTS_DEMO_DIR"
else
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
fi
mkdir -p "$WORK"
export ANALECTS_DB="$WORK/graph.db"
export ANALECTS_CONFIG="$WORK/analects.yaml"
Expand Down
Loading