openkos 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. openkos-0.1.0/PKG-INFO +176 -0
  2. openkos-0.1.0/README.md +143 -0
  3. openkos-0.1.0/pyproject.toml +149 -0
  4. openkos-0.1.0/src/openkos/__init__.py +1 -0
  5. openkos-0.1.0/src/openkos/bundle/__init__.py +4 -0
  6. openkos-0.1.0/src/openkos/bundle/bundle.py +28 -0
  7. openkos-0.1.0/src/openkos/bundle/index.py +229 -0
  8. openkos-0.1.0/src/openkos/bundle/links.py +274 -0
  9. openkos-0.1.0/src/openkos/bundle/log.py +162 -0
  10. openkos-0.1.0/src/openkos/bundle/merge.py +195 -0
  11. openkos-0.1.0/src/openkos/bundle/provenance.py +98 -0
  12. openkos-0.1.0/src/openkos/bundle/references.py +170 -0
  13. openkos-0.1.0/src/openkos/bundle/relations.py +229 -0
  14. openkos-0.1.0/src/openkos/cli/__init__.py +1 -0
  15. openkos-0.1.0/src/openkos/cli/main.py +4853 -0
  16. openkos-0.1.0/src/openkos/cli/observability.py +66 -0
  17. openkos-0.1.0/src/openkos/config.py +410 -0
  18. openkos-0.1.0/src/openkos/extraction/__init__.py +8 -0
  19. openkos-0.1.0/src/openkos/extraction/concept.py +231 -0
  20. openkos-0.1.0/src/openkos/fsio.py +97 -0
  21. openkos-0.1.0/src/openkos/graph/__init__.py +13 -0
  22. openkos-0.1.0/src/openkos/graph/analysis.py +39 -0
  23. openkos-0.1.0/src/openkos/graph/base.py +57 -0
  24. openkos-0.1.0/src/openkos/graph/sqlite_graph.py +439 -0
  25. openkos-0.1.0/src/openkos/lifecycle.py +98 -0
  26. openkos-0.1.0/src/openkos/lint.py +451 -0
  27. openkos-0.1.0/src/openkos/llm/__init__.py +9 -0
  28. openkos-0.1.0/src/openkos/llm/base.py +42 -0
  29. openkos-0.1.0/src/openkos/llm/ollama.py +336 -0
  30. openkos-0.1.0/src/openkos/llm/parsing.py +95 -0
  31. openkos-0.1.0/src/openkos/model/__init__.py +4 -0
  32. openkos-0.1.0/src/openkos/model/okf.py +1039 -0
  33. openkos-0.1.0/src/openkos/model/relations.py +68 -0
  34. openkos-0.1.0/src/openkos/model/types.py +88 -0
  35. openkos-0.1.0/src/openkos/py.typed +0 -0
  36. openkos-0.1.0/src/openkos/resolution/__init__.py +22 -0
  37. openkos-0.1.0/src/openkos/resolution/adjudication.py +269 -0
  38. openkos-0.1.0/src/openkos/resolution/candidates.py +195 -0
  39. openkos-0.1.0/src/openkos/resolution/contradiction.py +438 -0
  40. openkos-0.1.0/src/openkos/resolution/edge_typing.py +291 -0
  41. openkos-0.1.0/src/openkos/resolution/normalize.py +29 -0
  42. openkos-0.1.0/src/openkos/resolution/similarity.py +85 -0
  43. openkos-0.1.0/src/openkos/resolution/volatility_typing.py +281 -0
  44. openkos-0.1.0/src/openkos/retrieval/__init__.py +7 -0
  45. openkos-0.1.0/src/openkos/retrieval/answer.py +485 -0
  46. openkos-0.1.0/src/openkos/retrieval/fusion.py +81 -0
  47. openkos-0.1.0/src/openkos/retrieval/graph_retrieve.py +77 -0
  48. openkos-0.1.0/src/openkos/retrieval/pool.py +20 -0
  49. openkos-0.1.0/src/openkos/sensitivity.py +123 -0
  50. openkos-0.1.0/src/openkos/state/__init__.py +4 -0
  51. openkos-0.1.0/src/openkos/state/derived.py +227 -0
  52. openkos-0.1.0/src/openkos/state/fts.py +351 -0
  53. openkos-0.1.0/src/openkos/state/reindex.py +323 -0
  54. openkos-0.1.0/src/openkos/state/vectorstore.py +465 -0
  55. openkos-0.1.0/src/openkos/templates/agents.md.template +50 -0
  56. openkos-0.1.0/src/openkos/templates/openkos.yaml.template +15 -0
  57. openkos-0.1.0/src/openkos/vcs/__init__.py +6 -0
  58. openkos-0.1.0/src/openkos/vcs/git.py +512 -0
openkos-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: openkos
3
+ Version: 0.1.0
4
+ Summary: Local-first engine that turns your scattered text into a living, portable knowledge base in the Open Knowledge Format (OKF)
5
+ Keywords: okf,open-knowledge-format,knowledge-base,knowledge-graph,local-first,rag,llm,second-brain,cli
6
+ Author: Jason
7
+ Author-email: Jason <jasonssdev@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Text Processing :: Indexing
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: networkx>=3.4
22
+ Requires-Dist: python-frontmatter>=1.3.0
23
+ Requires-Dist: pyyaml>=6.0.3
24
+ Requires-Dist: scipy>=1.14
25
+ Requires-Dist: sqlite-vec>=0.1.6
26
+ Requires-Dist: typer>=0.27.0
27
+ Requires-Python: >=3.12
28
+ Project-URL: Homepage, https://github.com/jasonssdev/openkos
29
+ Project-URL: Repository, https://github.com/jasonssdev/openkos
30
+ Project-URL: Issues, https://github.com/jasonssdev/openkos/issues
31
+ Project-URL: Changelog, https://github.com/jasonssdev/openkos/blob/main/CHANGELOG.md
32
+ Description-Content-Type: text/markdown
33
+
34
+ # OpenKOS
35
+
36
+ **Open Knowledge Orchestration System** — a local-first engine for the Open Knowledge Format.
37
+
38
+ OpenKOS turns your scattered text into a living, portable knowledge base your AI agents can actually use — compiled once, kept current, and stored as plain [Open Knowledge Format](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf) files so it is never locked to any app, model, or vendor.
39
+
40
+ > **Project status: alpha.** OpenKOS runs: the Compiler and the Graph-and-Memory arcs (MVP 1 and MVP 2) are complete — 18 CLI verbs, hybrid retrieval, and the full forget/purge lifecycle all ship today. The API may still change, and there is no published release yet (no PyPI package, no tagged version) — but you can install straight from this repository today, see [Getting started](#getting-started). Early contributors and feedback are welcome — see [Contributing](#contributing).
41
+
42
+ ---
43
+
44
+ ## The problem
45
+
46
+ Your AI assistant forgets everything between sessions, so you re-explain the same context every time and the insights you build together disappear into chat history. Meanwhile your notes pile up in folders nobody keeps current. Two powerful things — your knowledge and your models — sit side by side, disconnected.
47
+
48
+ Retrieval (RAG) doesn't fix this: it re-reads your raw documents on every question and rediscovers everything from scratch. Nothing accumulates. The cross-references are never drawn, the contradictions never reconciled.
49
+
50
+ ## The idea
51
+
52
+ Instead of retrieving from raw sources every time, an LLM can *incrementally build and maintain* a persistent, interlinked knowledge base that sits between you and your sources — Andrej Karpathy's [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) pattern. Knowledge is compiled once and then kept current. It compounds.
53
+
54
+ In June 2026 Google Cloud published a vendor-neutral specification for that pattern: the **Open Knowledge Format (OKF)** — a directory of markdown files with YAML frontmatter, portable across any tool. It is young (v0.1, still a draft) but open, minimal, and gaining adoption. Google's framing was: *"What's missing is a format, not another service,"* and they invited the community to build producers and consumers.
55
+
56
+ **OpenKOS is that producer and consumer, built for individuals and running entirely on your machine.**
57
+
58
+ ## Before / after
59
+
60
+ | | Without OpenKOS | With OpenKOS |
61
+ | --- | --- | --- |
62
+ | Asking your AI about your own notes | It re-reads raw files every time | It answers from a compiled, cited knowledge base |
63
+ | New source | Piles up unread | Compiled into a Source plus typed knowledge objects, each linked to its source |
64
+ | Provenance | "Where did this come from?" is a guess | Every object links back to its immutable source |
65
+ | Facts that change | Old claims quietly rot | Freshness stamps keep the base honest over time |
66
+ | Portability | Trapped in one app | Plain OKF files — open in Obsidian, VS Code, GitHub, anything |
67
+ | Privacy | Your knowledge leaves your machine | Local-first, offline-capable, local models |
68
+
69
+ ## What it feels like
70
+
71
+ ```bash
72
+ # point OpenKOS at a folder of text and compile it into an OKF bundle
73
+ openkos ingest ./sources
74
+
75
+ # ask a question and get a cited answer from the compiled knowledge
76
+ openkos query "what did I conclude about how to live well?"
77
+
78
+ # check the base stays honest — stale `as of` stamps and orphan pages
79
+ openkos lint
80
+ ```
81
+
82
+ *(The full command set — 18 verbs spanning ingest, cited query, the typed graph, entity resolution, and the forget/purge lifecycle — is in [`docs/cli.md`](docs/cli.md).)*
83
+
84
+ ## Getting started
85
+
86
+ > Alpha: the commands below run today. OpenKOS is **not yet published to PyPI**, so for now install straight from the GitHub repository — no clone required. A published `pip install openkos` will follow once the API stabilizes.
87
+
88
+ OpenKOS is a local-first command-line tool. You install the engine once, then create a knowledge bundle per knowledge base — much like installing git once and running `git init` in many repositories.
89
+
90
+ **Prerequisites:** Python 3.12+; [git](https://git-scm.com); [git-filter-repo](https://github.com/newren/git-filter-repo) (only needed for `purge`); and a local model runtime — [Ollama](https://ollama.com) with the chat model (`ollama pull qwen3:8b`) and the embedding model (`ollama pull bge-m3`) pulled. No accounts, no API keys: nothing leaves your machine.
91
+
92
+ **Install the engine** (once, from the repository):
93
+
94
+ ```bash
95
+ uv tool install git+https://github.com/jasonssdev/openkos # or: pipx install git+https://github.com/jasonssdev/openkos
96
+ ```
97
+
98
+ This installs the `openkos` command on your PATH. To try it once without a persistent install, run it ephemerally instead:
99
+
100
+ ```bash
101
+ uvx --from git+https://github.com/jasonssdev/openkos openkos --help
102
+ ```
103
+
104
+ To upgrade later, re-run the install command (uv reinstalls from the latest `main`). Once OpenKOS reaches PyPI, this becomes `uv tool install openkos` — no git URL needed.
105
+
106
+ **Create a bundle** (per knowledge base):
107
+
108
+ ```bash
109
+ mkdir ~/knowledge && cd ~/knowledge
110
+ openkos init
111
+ ```
112
+
113
+ `init` scaffolds the workspace — `raw/` for your immutable sources and `bundle/` for the compiled OKF bundle (starting with just `index.md` and `log.md`; concept-type folders are never pre-created, only added as you ingest) — then writes `AGENTS.md` and, last, the `openkos.yaml` marker. It refuses without writing anything if the directory already looks like a workspace. Sources sit beside the bundle rather than inside it, so `bundle/` stays pure OKF: portable, conformant, and shareable on its own.
114
+
115
+ **Then the loop:**
116
+
117
+ ```bash
118
+ openkos ingest ./meeting-notes.txt # compile a source into the bundle
119
+ openkos query "what did we decide?" # get a cited answer
120
+ ```
121
+
122
+ See [`docs/cli.md`](docs/cli.md) for the full command reference and [`docs/user-journey.md`](docs/user-journey.md) for the end-to-end experience.
123
+
124
+ ## Philosophy
125
+
126
+ - **Local-first and private by default.** Runs on your machine, works offline, built for local models. The cloud is optional, never required.
127
+ - **Standard-aligned, not bespoke.** We adopt OKF rather than invent a format, and adopt its definitions rather than restate them. An open, vendor-neutral specification is the most agnostic choice there is.
128
+ - **Living knowledge, honest over time.** Sources are immutable; concept documents evolve as you learn; fast-changing facts carry freshness stamps so nothing silently becomes a lie.
129
+ - **The human curates; the engine maintains.** You source, explore, and ask. OpenKOS does the bookkeeping — extraction, linking, freshness, indexing.
130
+ - **Reconstructible and explainable.** Every index, embedding, and graph rebuilds from the canonical bundle plus sources. Answers always cite.
131
+
132
+ ## How OpenKOS relates to the ecosystem
133
+
134
+ We build on the shoulders of prior work rather than competing with it:
135
+
136
+ - **[Karpathy's LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)** — the seminal pattern. OpenKOS is a concrete engine that instantiates it.
137
+ - **[Open Knowledge Format](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing)** (Google Cloud) — the standard we store and exchange in. Google's reference stack targets enterprise cloud data (BigQuery); OpenKOS is its local-first, personal counterpart.
138
+ - **Obsidian-based tools** (obsidian-mind, obsidian-second-brain) — excellent, but tied to Obsidian and packaged as prompt/skill conventions. OpenKOS is a standalone, app-agnostic engine whose output is portable OKF.
139
+
140
+ The wedge, in one line: **the local-first, personal producer-consumer-runtime for OKF that nobody else has built.**
141
+
142
+ ## Roadmap at a glance
143
+
144
+ OpenKOS ships in three MVP arcs, each usable on its own. Full detail in [`docs/roadmap.md`](docs/roadmap.md).
145
+
146
+ - **MVP 1 — The Compiler. (Complete.)** The Karpathy loop, locally, over text: ingest → OKF concepts with provenance → cited query → freshness lint. Useful in an afternoon.
147
+ - **MVP 2 — The Graph and Memory. (Complete.)** Entity/relationship extraction and reversible merge, a typed knowledge graph (an OpenKOS layer over OKF's untyped links — other tools still read the bundle fine), hybrid retrieval (lexical FTS5 + local vectors + graph, fused via RRF with PageRank), a fail-closed sensitivity filter (confidential concepts never reach the LLM), reference-aware `forget` plus an irreversible `purge` (right-to-be-forgotten), and answers that file back into the base (`query --save`, the two-output rule).
148
+ - **MVP 3 — The Runtime and Interoperability.** An MCP server and APIs so agents use OpenKOS as durable memory; full OKF import/export with the wider ecosystem.
149
+
150
+ Beyond that: a desktop app, graph visualization, richer memory, and federation — explored only after the MVPs prove out with real users.
151
+
152
+ ## Documentation
153
+
154
+ - [`docs/vision.md`](docs/vision.md) — vision, philosophy, and positioning
155
+ - [`docs/philosophy.md`](docs/philosophy.md) — the foundational essay: what knowledge is and why OpenKOS matters
156
+ - [`docs/knowledge-object-model.md`](docs/knowledge-object-model.md) — how knowledge is represented (OKF + the OpenKOS layer)
157
+ - [`docs/roadmap.md`](docs/roadmap.md) — the MVP roadmap
158
+ - [`docs/tech_stack.md`](docs/tech_stack.md) — technology choices
159
+ - [`docs/architecture.md`](docs/architecture.md) — repository and bundle structure, and source versioning
160
+ - [`docs/okf-alignment.md`](docs/okf-alignment.md) — how OpenKOS relates to OKF
161
+ - [`docs/glossary.md`](docs/glossary.md) — definitions of the core vocabulary
162
+ - [`docs/faq.md`](docs/faq.md) — frequently asked questions
163
+ - [`docs/user-journey.md`](docs/user-journey.md) — the end-to-end user experience
164
+ - [`docs/cli.md`](docs/cli.md) — the command-line reference
165
+ - [`docs/brand.md`](docs/brand.md) — visual identity: isotype, wordmark, palette, typography
166
+ - [`docs/adr/`](docs/adr/) — architecture decision records (the log begins with the first code-time decision)
167
+
168
+ ## Contributing
169
+
170
+ OpenKOS is early, which is the best time to shape it. The clearest entry points are the "community can contribute" notes under the current MVP in the [roadmap](docs/roadmap.md). Please open an issue to discuss anything larger than a small change before sending a PR, so we can make sure it fits and can be merged.
171
+
172
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to get involved and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards. Maintainers: see [MAINTAINERS.md](MAINTAINERS.md) for how contributions are reviewed and decided.
173
+
174
+ ## License
175
+
176
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,143 @@
1
+ # OpenKOS
2
+
3
+ **Open Knowledge Orchestration System** — a local-first engine for the Open Knowledge Format.
4
+
5
+ OpenKOS turns your scattered text into a living, portable knowledge base your AI agents can actually use — compiled once, kept current, and stored as plain [Open Knowledge Format](https://github.com/GoogleCloudPlatform/knowledge-catalog/tree/main/okf) files so it is never locked to any app, model, or vendor.
6
+
7
+ > **Project status: alpha.** OpenKOS runs: the Compiler and the Graph-and-Memory arcs (MVP 1 and MVP 2) are complete — 18 CLI verbs, hybrid retrieval, and the full forget/purge lifecycle all ship today. The API may still change, and there is no published release yet (no PyPI package, no tagged version) — but you can install straight from this repository today, see [Getting started](#getting-started). Early contributors and feedback are welcome — see [Contributing](#contributing).
8
+
9
+ ---
10
+
11
+ ## The problem
12
+
13
+ Your AI assistant forgets everything between sessions, so you re-explain the same context every time and the insights you build together disappear into chat history. Meanwhile your notes pile up in folders nobody keeps current. Two powerful things — your knowledge and your models — sit side by side, disconnected.
14
+
15
+ Retrieval (RAG) doesn't fix this: it re-reads your raw documents on every question and rediscovers everything from scratch. Nothing accumulates. The cross-references are never drawn, the contradictions never reconciled.
16
+
17
+ ## The idea
18
+
19
+ Instead of retrieving from raw sources every time, an LLM can *incrementally build and maintain* a persistent, interlinked knowledge base that sits between you and your sources — Andrej Karpathy's [LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) pattern. Knowledge is compiled once and then kept current. It compounds.
20
+
21
+ In June 2026 Google Cloud published a vendor-neutral specification for that pattern: the **Open Knowledge Format (OKF)** — a directory of markdown files with YAML frontmatter, portable across any tool. It is young (v0.1, still a draft) but open, minimal, and gaining adoption. Google's framing was: *"What's missing is a format, not another service,"* and they invited the community to build producers and consumers.
22
+
23
+ **OpenKOS is that producer and consumer, built for individuals and running entirely on your machine.**
24
+
25
+ ## Before / after
26
+
27
+ | | Without OpenKOS | With OpenKOS |
28
+ | --- | --- | --- |
29
+ | Asking your AI about your own notes | It re-reads raw files every time | It answers from a compiled, cited knowledge base |
30
+ | New source | Piles up unread | Compiled into a Source plus typed knowledge objects, each linked to its source |
31
+ | Provenance | "Where did this come from?" is a guess | Every object links back to its immutable source |
32
+ | Facts that change | Old claims quietly rot | Freshness stamps keep the base honest over time |
33
+ | Portability | Trapped in one app | Plain OKF files — open in Obsidian, VS Code, GitHub, anything |
34
+ | Privacy | Your knowledge leaves your machine | Local-first, offline-capable, local models |
35
+
36
+ ## What it feels like
37
+
38
+ ```bash
39
+ # point OpenKOS at a folder of text and compile it into an OKF bundle
40
+ openkos ingest ./sources
41
+
42
+ # ask a question and get a cited answer from the compiled knowledge
43
+ openkos query "what did I conclude about how to live well?"
44
+
45
+ # check the base stays honest — stale `as of` stamps and orphan pages
46
+ openkos lint
47
+ ```
48
+
49
+ *(The full command set — 18 verbs spanning ingest, cited query, the typed graph, entity resolution, and the forget/purge lifecycle — is in [`docs/cli.md`](docs/cli.md).)*
50
+
51
+ ## Getting started
52
+
53
+ > Alpha: the commands below run today. OpenKOS is **not yet published to PyPI**, so for now install straight from the GitHub repository — no clone required. A published `pip install openkos` will follow once the API stabilizes.
54
+
55
+ OpenKOS is a local-first command-line tool. You install the engine once, then create a knowledge bundle per knowledge base — much like installing git once and running `git init` in many repositories.
56
+
57
+ **Prerequisites:** Python 3.12+; [git](https://git-scm.com); [git-filter-repo](https://github.com/newren/git-filter-repo) (only needed for `purge`); and a local model runtime — [Ollama](https://ollama.com) with the chat model (`ollama pull qwen3:8b`) and the embedding model (`ollama pull bge-m3`) pulled. No accounts, no API keys: nothing leaves your machine.
58
+
59
+ **Install the engine** (once, from the repository):
60
+
61
+ ```bash
62
+ uv tool install git+https://github.com/jasonssdev/openkos # or: pipx install git+https://github.com/jasonssdev/openkos
63
+ ```
64
+
65
+ This installs the `openkos` command on your PATH. To try it once without a persistent install, run it ephemerally instead:
66
+
67
+ ```bash
68
+ uvx --from git+https://github.com/jasonssdev/openkos openkos --help
69
+ ```
70
+
71
+ To upgrade later, re-run the install command (uv reinstalls from the latest `main`). Once OpenKOS reaches PyPI, this becomes `uv tool install openkos` — no git URL needed.
72
+
73
+ **Create a bundle** (per knowledge base):
74
+
75
+ ```bash
76
+ mkdir ~/knowledge && cd ~/knowledge
77
+ openkos init
78
+ ```
79
+
80
+ `init` scaffolds the workspace — `raw/` for your immutable sources and `bundle/` for the compiled OKF bundle (starting with just `index.md` and `log.md`; concept-type folders are never pre-created, only added as you ingest) — then writes `AGENTS.md` and, last, the `openkos.yaml` marker. It refuses without writing anything if the directory already looks like a workspace. Sources sit beside the bundle rather than inside it, so `bundle/` stays pure OKF: portable, conformant, and shareable on its own.
81
+
82
+ **Then the loop:**
83
+
84
+ ```bash
85
+ openkos ingest ./meeting-notes.txt # compile a source into the bundle
86
+ openkos query "what did we decide?" # get a cited answer
87
+ ```
88
+
89
+ See [`docs/cli.md`](docs/cli.md) for the full command reference and [`docs/user-journey.md`](docs/user-journey.md) for the end-to-end experience.
90
+
91
+ ## Philosophy
92
+
93
+ - **Local-first and private by default.** Runs on your machine, works offline, built for local models. The cloud is optional, never required.
94
+ - **Standard-aligned, not bespoke.** We adopt OKF rather than invent a format, and adopt its definitions rather than restate them. An open, vendor-neutral specification is the most agnostic choice there is.
95
+ - **Living knowledge, honest over time.** Sources are immutable; concept documents evolve as you learn; fast-changing facts carry freshness stamps so nothing silently becomes a lie.
96
+ - **The human curates; the engine maintains.** You source, explore, and ask. OpenKOS does the bookkeeping — extraction, linking, freshness, indexing.
97
+ - **Reconstructible and explainable.** Every index, embedding, and graph rebuilds from the canonical bundle plus sources. Answers always cite.
98
+
99
+ ## How OpenKOS relates to the ecosystem
100
+
101
+ We build on the shoulders of prior work rather than competing with it:
102
+
103
+ - **[Karpathy's LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)** — the seminal pattern. OpenKOS is a concrete engine that instantiates it.
104
+ - **[Open Knowledge Format](https://cloud.google.com/blog/products/data-analytics/how-the-open-knowledge-format-can-improve-data-sharing)** (Google Cloud) — the standard we store and exchange in. Google's reference stack targets enterprise cloud data (BigQuery); OpenKOS is its local-first, personal counterpart.
105
+ - **Obsidian-based tools** (obsidian-mind, obsidian-second-brain) — excellent, but tied to Obsidian and packaged as prompt/skill conventions. OpenKOS is a standalone, app-agnostic engine whose output is portable OKF.
106
+
107
+ The wedge, in one line: **the local-first, personal producer-consumer-runtime for OKF that nobody else has built.**
108
+
109
+ ## Roadmap at a glance
110
+
111
+ OpenKOS ships in three MVP arcs, each usable on its own. Full detail in [`docs/roadmap.md`](docs/roadmap.md).
112
+
113
+ - **MVP 1 — The Compiler. (Complete.)** The Karpathy loop, locally, over text: ingest → OKF concepts with provenance → cited query → freshness lint. Useful in an afternoon.
114
+ - **MVP 2 — The Graph and Memory. (Complete.)** Entity/relationship extraction and reversible merge, a typed knowledge graph (an OpenKOS layer over OKF's untyped links — other tools still read the bundle fine), hybrid retrieval (lexical FTS5 + local vectors + graph, fused via RRF with PageRank), a fail-closed sensitivity filter (confidential concepts never reach the LLM), reference-aware `forget` plus an irreversible `purge` (right-to-be-forgotten), and answers that file back into the base (`query --save`, the two-output rule).
115
+ - **MVP 3 — The Runtime and Interoperability.** An MCP server and APIs so agents use OpenKOS as durable memory; full OKF import/export with the wider ecosystem.
116
+
117
+ Beyond that: a desktop app, graph visualization, richer memory, and federation — explored only after the MVPs prove out with real users.
118
+
119
+ ## Documentation
120
+
121
+ - [`docs/vision.md`](docs/vision.md) — vision, philosophy, and positioning
122
+ - [`docs/philosophy.md`](docs/philosophy.md) — the foundational essay: what knowledge is and why OpenKOS matters
123
+ - [`docs/knowledge-object-model.md`](docs/knowledge-object-model.md) — how knowledge is represented (OKF + the OpenKOS layer)
124
+ - [`docs/roadmap.md`](docs/roadmap.md) — the MVP roadmap
125
+ - [`docs/tech_stack.md`](docs/tech_stack.md) — technology choices
126
+ - [`docs/architecture.md`](docs/architecture.md) — repository and bundle structure, and source versioning
127
+ - [`docs/okf-alignment.md`](docs/okf-alignment.md) — how OpenKOS relates to OKF
128
+ - [`docs/glossary.md`](docs/glossary.md) — definitions of the core vocabulary
129
+ - [`docs/faq.md`](docs/faq.md) — frequently asked questions
130
+ - [`docs/user-journey.md`](docs/user-journey.md) — the end-to-end user experience
131
+ - [`docs/cli.md`](docs/cli.md) — the command-line reference
132
+ - [`docs/brand.md`](docs/brand.md) — visual identity: isotype, wordmark, palette, typography
133
+ - [`docs/adr/`](docs/adr/) — architecture decision records (the log begins with the first code-time decision)
134
+
135
+ ## Contributing
136
+
137
+ OpenKOS is early, which is the best time to shape it. The clearest entry points are the "community can contribute" notes under the current MVP in the [roadmap](docs/roadmap.md). Please open an issue to discuss anything larger than a small change before sending a PR, so we can make sure it fits and can be merged.
138
+
139
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to get involved and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards. Maintainers: see [MAINTAINERS.md](MAINTAINERS.md) for how contributions are reviewed and decided.
140
+
141
+ ## License
142
+
143
+ Apache License 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,149 @@
1
+ [project]
2
+ name = "openkos"
3
+ version = "0.1.0"
4
+ description = "Local-first engine that turns your scattered text into a living, portable knowledge base in the Open Knowledge Format (OKF)"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ authors = [
8
+ { name = "Jason", email = "jasonssdev@gmail.com" }
9
+ ]
10
+ requires-python = ">=3.12"
11
+ keywords = [
12
+ "okf",
13
+ "open-knowledge-format",
14
+ "knowledge-base",
15
+ "knowledge-graph",
16
+ "local-first",
17
+ "rag",
18
+ "llm",
19
+ "second-brain",
20
+ "cli",
21
+ ]
22
+ # The `License ::` trove classifier is deliberately omitted: `license` above is
23
+ # an SPDX expression (PEP 639), and declaring the license twice makes modern
24
+ # build backends warn or fail. The SPDX string is the single source of truth.
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Environment :: Console",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: End Users/Desktop",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Programming Language :: Python :: 3.13",
34
+ "Programming Language :: Python :: 3.14",
35
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
36
+ "Topic :: Text Processing :: Indexing",
37
+ "Typing :: Typed",
38
+ ]
39
+ dependencies = [
40
+ "networkx>=3.4",
41
+ "python-frontmatter>=1.3.0",
42
+ "pyyaml>=6.0.3",
43
+ "scipy>=1.14",
44
+ "sqlite-vec>=0.1.6",
45
+ "typer>=0.27.0",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/jasonssdev/openkos"
50
+ Repository = "https://github.com/jasonssdev/openkos"
51
+ Issues = "https://github.com/jasonssdev/openkos/issues"
52
+ Changelog = "https://github.com/jasonssdev/openkos/blob/main/CHANGELOG.md"
53
+
54
+ [project.scripts]
55
+ openkos = "openkos.cli.main:app"
56
+
57
+ [build-system]
58
+ requires = ["uv_build>=0.11.29,<0.12.0"]
59
+ build-backend = "uv_build"
60
+
61
+ [dependency-groups]
62
+ dev = [
63
+ "git-filter-repo>=2.47.0",
64
+ "mypy>=2.3.0",
65
+ "pre-commit>=4.6.0",
66
+ "pydantic>=2.13.4",
67
+ "pytest>=9.1.1",
68
+ "pytest-cov>=7.1.0",
69
+ "ruamel-yaml>=0.19.1",
70
+ "ruff>=0.15.21",
71
+ "types-networkx>=3.6.1.20260624",
72
+ "types-pyyaml>=6.0.12.20260518",
73
+ ]
74
+
75
+ [tool.pytest.ini_options]
76
+ testpaths = ["tests"]
77
+ addopts = ["--import-mode=importlib"]
78
+
79
+ # Coverage is opt-in: `--cov` is deliberately not in pytest's addopts, so plain
80
+ # `uv run pytest` stays fast for the local loop. CI passes `--cov`, and because
81
+ # the gate lives here, a local `uv run pytest --cov` gates identically to CI.
82
+ [tool.coverage.run]
83
+ source = ["openkos"]
84
+ # Line coverage alone lets an `if` that never goes both ways read as covered;
85
+ # branch coverage counts each direction.
86
+ branch = true
87
+
88
+ [tool.coverage.report]
89
+ fail_under = 90
90
+ show_missing = true
91
+
92
+ # Ruff infers `target-version` from `project.requires-python` (3.12) and
93
+ # defaults `line-length` to 88; neither is restated here. The formatter runs on
94
+ # defaults, so there is no [tool.ruff.format] section.
95
+
96
+ [tool.ruff.lint]
97
+ select = [
98
+ "E", # pycodestyle errors
99
+ "F", # Pyflakes: undefined names, unused imports
100
+ "I", # isort: deterministic import order, keeps the layering rule auditable
101
+ "UP", # pyupgrade: the 3.12 floor means no back-compat idioms are needed
102
+ "B", # bugbear: mutable defaults, `raise ... from`, unstrict `zip`
103
+ "SIM", # flake8-simplify
104
+ "S", # bandit: untrusted user text, YAML frontmatter, git subprocess
105
+ "DTZ", # naive datetimes would corrupt OKF `as of` / freshness stamps
106
+ "PT", # flake8-pytest-style: tests are a first-class quality gate
107
+ "PTH", # pathlib: the engine is filesystem-centric and must stay portable
108
+ "RUF", # Ruff-specific, incl. RUF100 (unused noqa) to keep suppressions honest
109
+ ]
110
+ ignore = [
111
+ "E501", # line length is the formatter's job; E501 only fights it on long strings/URLs
112
+ ]
113
+
114
+ [tool.ruff.lint.per-file-ignores]
115
+ "tests/**/*.py" = [
116
+ "S101", # `assert` is what a test is made of
117
+ ]
118
+
119
+ [tool.ruff.lint.flake8-bugbear]
120
+ # `typer.Argument(...)`/`typer.Option(...)` in a parameter default is the
121
+ # idiomatic Typer CLI pattern (B008 normally flags a mutable default called
122
+ # at definition time), and both are effectively immutable declarative
123
+ # markers, not runtime state. `bool`/`str | None`-annotated parameters are
124
+ # already exempt by B008's own immutable-type check; `Path`-annotated ones
125
+ # (e.g. `ingest`'s `src` argument) are not, so both callables are listed
126
+ # explicitly here for consistency across every future Typer command.
127
+ extend-immutable-calls = ["typer.Argument", "typer.Option"]
128
+
129
+ [tool.mypy]
130
+ # Pin the analysis target to the declared floor so a contributor on a newer
131
+ # interpreter cannot merge code that is broken on 3.12.
132
+ python_version = "3.12"
133
+ files = ["src", "tests"]
134
+ strict = true
135
+ # Not implied by `strict`: dead code left by a wrong narrowing is a real bug,
136
+ # and `py.typed` means our type errors become our consumers' type errors.
137
+ warn_unreachable = true
138
+ enable_error_code = [
139
+ "ignore-without-code", # a bare `# type: ignore` silences more than it claims
140
+ "redundant-expr",
141
+ "truthy-bool", # catches `if obj:` on an always-truthy object
142
+ "possibly-undefined",
143
+ ]
144
+
145
+ # `sqlite-vec` ships no type stubs; this keeps `mypy . --strict` (repo-wide,
146
+ # incl. tests) green without weakening `strict` for the rest of the codebase.
147
+ [[tool.mypy.overrides]]
148
+ module = "sqlite_vec.*"
149
+ ignore_missing_imports = true
@@ -0,0 +1 @@
1
+ """openkos: local-first engine that compiles text into a portable knowledge base."""
@@ -0,0 +1,4 @@
1
+ """Canonical OKF bundle: the rendered and written shape of `bundle/`.
2
+
3
+ Never imports from the derived layer (`retrieval`, `graph`, `memory`).
4
+ """
@@ -0,0 +1,28 @@
1
+ """Writes the OKF bundle root: `index.md` and `log.md`.
2
+
3
+ The only module in `bundle/` that touches the filesystem — `index.py` and
4
+ `log.py` stay pure renderers.
5
+ """
6
+
7
+ from datetime import date
8
+ from pathlib import Path
9
+
10
+ from openkos import fsio
11
+ from openkos.bundle.index import render_index
12
+ from openkos.bundle.log import render_log
13
+
14
+
15
+ def create(bundle_dir: Path, today: date) -> None:
16
+ """Create a fresh bundle at `bundle_dir`: `index.md` then `log.md`.
17
+
18
+ Both files are written with exclusive-create mode ("x"): a colliding
19
+ file raises `FileExistsError` instead of being overwritten (D2). This
20
+ closes the Phase-A -> B TOCTOU window only for these two leaf files —
21
+ NOT for `bundle_dir.mkdir(parents=True, exist_ok=True)` above, where a
22
+ racing writer adding a non-colliding file is silently absorbed (known,
23
+ accepted limitation, D2). No cleanup path on a mid-write failure (D3): a
24
+ partially written bundle is left as-is for manual recovery.
25
+ """
26
+ bundle_dir.mkdir(parents=True, exist_ok=True)
27
+ fsio.write_exclusive(bundle_dir / "index.md", render_index())
28
+ fsio.write_exclusive(bundle_dir / "log.md", render_log(today))