arkiv 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.
- arkiv-0.1.0/.claude/settings.local.json +10 -0
- arkiv-0.1.0/.coveragerc +10 -0
- arkiv-0.1.0/.gitignore +20 -0
- arkiv-0.1.0/CLAUDE.md +143 -0
- arkiv-0.1.0/LICENSE +21 -0
- arkiv-0.1.0/PKG-INFO +92 -0
- arkiv-0.1.0/README.md +58 -0
- arkiv-0.1.0/SPEC.md +530 -0
- arkiv-0.1.0/docs/plans/2026-02-17-arkiv-implementation.md +1760 -0
- arkiv-0.1.0/docs/plans/2026-02-24-remove-manifest-curate-examples.md +358 -0
- arkiv-0.1.0/docs/plans/2026-03-15-export-enrichments.md +1091 -0
- arkiv-0.1.0/docs/plans/2026-03-16-write-record-mcp-tool.md +299 -0
- arkiv-0.1.0/docs/specs/2026-03-15-export-enrichments-design.md +286 -0
- arkiv-0.1.0/examples/repos/README.md +15 -0
- arkiv-0.1.0/examples/repos/repos.jsonl +5 -0
- arkiv-0.1.0/examples/repos/schema.yaml +41 -0
- arkiv-0.1.0/pyproject.toml +57 -0
- arkiv-0.1.0/src/arkiv/__init__.py +29 -0
- arkiv-0.1.0/src/arkiv/__main__.py +6 -0
- arkiv-0.1.0/src/arkiv/cli.py +393 -0
- arkiv-0.1.0/src/arkiv/database.py +569 -0
- arkiv-0.1.0/src/arkiv/readme.py +86 -0
- arkiv-0.1.0/src/arkiv/record.py +75 -0
- arkiv-0.1.0/src/arkiv/render.py +89 -0
- arkiv-0.1.0/src/arkiv/schema.py +215 -0
- arkiv-0.1.0/src/arkiv/server.py +118 -0
- arkiv-0.1.0/src/arkiv/timefilter.py +84 -0
- arkiv-0.1.0/tests/__init__.py +0 -0
- arkiv-0.1.0/tests/test_cli.py +399 -0
- arkiv-0.1.0/tests/test_coverage_gaps.py +439 -0
- arkiv-0.1.0/tests/test_database.py +451 -0
- arkiv-0.1.0/tests/test_export.py +375 -0
- arkiv-0.1.0/tests/test_integration.py +143 -0
- arkiv-0.1.0/tests/test_readme.py +180 -0
- arkiv-0.1.0/tests/test_readme_import.py +215 -0
- arkiv-0.1.0/tests/test_record.py +123 -0
- arkiv-0.1.0/tests/test_render.py +185 -0
- arkiv-0.1.0/tests/test_schema.py +254 -0
- arkiv-0.1.0/tests/test_server.py +126 -0
- arkiv-0.1.0/tests/test_timefilter.py +54 -0
arkiv-0.1.0/.coveragerc
ADDED
arkiv-0.1.0/.gitignore
ADDED
arkiv-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What arkiv Is
|
|
6
|
+
|
|
7
|
+
Universal personal data format with JSONL canonical storage, SQLite query layer, and MCP server.
|
|
8
|
+
|
|
9
|
+
- **JSONL** is the source of truth (human-readable, portable, mergeable)
|
|
10
|
+
- **SQLite** is the derived query layer (efficient, standard SQL, JSON1 extension)
|
|
11
|
+
- **MCP server** exposes 3 tools: `get_manifest()`, `get_schema()`, `sql_query()`
|
|
12
|
+
|
|
13
|
+
## What arkiv Is NOT
|
|
14
|
+
|
|
15
|
+
- Not a database -- it's a format with tooling
|
|
16
|
+
- Not specific to personas -- longshade is one consumer, but arkiv is general-purpose
|
|
17
|
+
- Not a replacement for SQL databases -- it's an interchange format that imports/exports to SQLite
|
|
18
|
+
|
|
19
|
+
## Development Commands
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install -e ".[dev]"
|
|
23
|
+
pytest # all tests
|
|
24
|
+
pytest tests/test_database.py -v # one test file
|
|
25
|
+
pytest tests/test_cli.py::TestCLI::test_export -v # single test
|
|
26
|
+
pytest --cov=src/arkiv --cov-report=term-missing # coverage
|
|
27
|
+
black src/ tests/
|
|
28
|
+
flake8 src/ tests/
|
|
29
|
+
mypy src/
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
CLI is invoked as `python -m arkiv.cli` (or `arkiv` if installed). Tests use `subprocess.run([sys.executable, "-m", "arkiv.cli", ...])`.
|
|
33
|
+
|
|
34
|
+
## Architecture
|
|
35
|
+
|
|
36
|
+
### Data Flow
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
README.md + schema.yaml + *.jsonl (archive directory)
|
|
40
|
+
↓ import_readme()
|
|
41
|
+
SQLite database (3 tables: records, _schema, _metadata)
|
|
42
|
+
↓ export()
|
|
43
|
+
README.md + schema.yaml + *.jsonl (roundtrip-safe)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Record Model (`record.py`)
|
|
47
|
+
|
|
48
|
+
All fields optional: `mimetype`, `uri`, `content`, `timestamp`, `metadata`. Unknown fields on input are merged into `metadata`. Defined in `KNOWN_FIELDS`.
|
|
49
|
+
|
|
50
|
+
### Schema System (`schema.py`)
|
|
51
|
+
|
|
52
|
+
Two-tier schema: auto-discovered from data and curated from `schema.yaml`.
|
|
53
|
+
|
|
54
|
+
- `discover_schema()` scans JSONL and produces `Dict[str, SchemaEntry]` with type, count, values/example
|
|
55
|
+
- `merge_schema(auto, curated)` combines them: **live fields** (type, count) from auto, **stable fields** (description, curated values) from curated. Keys in curated but not data preserved with `count=0`
|
|
56
|
+
- `CollectionSchema` bundles `record_count` + `metadata_keys`
|
|
57
|
+
- `load_schema_yaml()` / `save_schema_yaml()` handle YAML I/O
|
|
58
|
+
|
|
59
|
+
### Database (`database.py`)
|
|
60
|
+
|
|
61
|
+
SQLite tables:
|
|
62
|
+
- `records` -- (id, collection, mimetype, uri, content, timestamp, metadata JSON)
|
|
63
|
+
- `_schema` -- (collection, key_path, type, count, sample_values, description)
|
|
64
|
+
- `_metadata` -- (key TEXT PRIMARY KEY, value TEXT) — stores README frontmatter + body as KV pairs
|
|
65
|
+
|
|
66
|
+
Key behaviors:
|
|
67
|
+
- `import_jsonl()` uses **replace semantics** (deletes existing records for same collection before inserting)
|
|
68
|
+
- `import_jsonl()` preserves existing schema descriptions across reimports via `_load_schema_descriptions()`
|
|
69
|
+
- `import_readme()` parses README.md frontmatter, imports each JSONL from `contents` (resolves paths relative to README, so nested `collection/collection.jsonl` paths work), merges curated schema from sibling `schema.yaml`
|
|
70
|
+
- `_save_schema_entries()` is the shared helper for writing to `_schema` table (used by both `import_jsonl` and `merge_curated_schema`)
|
|
71
|
+
- `_store_readme_metadata()` / `_load_readme_metadata()` serialize README frontmatter + body to/from `_metadata` KV table
|
|
72
|
+
- `export()` writes JSONL files + README.md + schema.yaml, preserving stored frontmatter metadata. Supports `nested` (per-collection subdirectories with own README + schema.yaml), `since`/`until` (temporal slicing with two-pass schema recomputation from filtered data), and schema-in-README injection via `render.py` sentinels
|
|
73
|
+
- `get_readme()` is the public accessor for stored README metadata
|
|
74
|
+
- `query()` is read-only (SELECT/WITH prefix check + sqlite3 authorizer)
|
|
75
|
+
|
|
76
|
+
### README / Archive Identity (`readme.py`)
|
|
77
|
+
|
|
78
|
+
`Readme` dataclass with `frontmatter: dict` and `body: str`. Frontmatter is `---`-delimited YAML. Known frontmatter keys by convention: `name`, `description`, `datetime`, `generator`, `contents`.
|
|
79
|
+
|
|
80
|
+
### CLI (`cli.py`)
|
|
81
|
+
|
|
82
|
+
Subcommands: `import`, `export`, `schema`, `query`, `info`, `detect`, `fix`, `mcp`. Export flags: `--nested` (per-collection subdirectories), `--since`/`--until` (temporal slicing). Import routing: `.md` → `import_readme()`, directory → looks for `README.md`, everything else → `import_jsonl()`. The CLI uses lazy imports (`from .database import Database` inside functions) to keep startup fast.
|
|
83
|
+
|
|
84
|
+
### Schema Rendering (`render.py`)
|
|
85
|
+
|
|
86
|
+
`render_schema_summary()` and `render_schema_detail()` produce markdown tables from `CollectionSchema`. `inject_schema_block()` handles sentinel-based injection into README bodies (`<!-- arkiv:schema:begin/end -->`). Used by `export()`.
|
|
87
|
+
|
|
88
|
+
### Temporal Filtering (`timefilter.py`)
|
|
89
|
+
|
|
90
|
+
`increment_iso_prefix()` handles ISO 8601 date arithmetic. `build_time_filter()` constructs SQL WHERE clauses for `--since`/`--until`. Used by `export()`.
|
|
91
|
+
|
|
92
|
+
### MCP Server (`server.py`)
|
|
93
|
+
|
|
94
|
+
`ArkivServer` wraps a read-only `Database`. `run_mcp_server()` uses FastMCP (requires `pip install arkiv[mcp]`). All metadata is derived from the DB — no external files needed at serve time.
|
|
95
|
+
|
|
96
|
+
## Archive Format
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
archive/
|
|
100
|
+
├── README.md # Self-description (YAML frontmatter + markdown)
|
|
101
|
+
├── schema.yaml # Structured metadata schema (auto-generated, curatable)
|
|
102
|
+
├── conversations.jsonl
|
|
103
|
+
└── bookmarks.jsonl
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
With `--nested` export:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
archive/
|
|
110
|
+
├── README.md
|
|
111
|
+
├── schema.yaml
|
|
112
|
+
├── conversations/
|
|
113
|
+
│ ├── README.md
|
|
114
|
+
│ ├── schema.yaml
|
|
115
|
+
│ └── conversations.jsonl
|
|
116
|
+
└── bookmarks/
|
|
117
|
+
├── README.md
|
|
118
|
+
├── schema.yaml
|
|
119
|
+
└── bookmarks.jsonl
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- **README.md** -- YAML frontmatter (`name`, `description`, `datetime`, `generator`, `contents`) + markdown body
|
|
123
|
+
- **schema.yaml** -- per-collection metadata keys with type, count, values, description
|
|
124
|
+
- **Merge-on-import** -- live fields (type, count) recomputed from data; stable fields (description, curated values) preserved
|
|
125
|
+
|
|
126
|
+
A curated example archive lives at `examples/repos/` and is verified by `test_integration.py::test_example_archive_roundtrip`.
|
|
127
|
+
|
|
128
|
+
## Key Principles
|
|
129
|
+
|
|
130
|
+
1. All record fields optional -- permissive input, best-effort processing
|
|
131
|
+
2. JSONL canonical, SQLite derived -- can always regenerate the DB from JSONL
|
|
132
|
+
3. Standards-based -- MIME types, URIs, ISO 8601, SQL
|
|
133
|
+
4. Document-oriented, not relational
|
|
134
|
+
|
|
135
|
+
## Tech Stack
|
|
136
|
+
|
|
137
|
+
- Python 3.8+, sqlite3 (stdlib), json (stdlib), pyyaml, MCP Python SDK
|
|
138
|
+
|
|
139
|
+
## Related Projects
|
|
140
|
+
|
|
141
|
+
- [longshade](../longshade/) -- Persona packaging convention (consumer of arkiv)
|
|
142
|
+
- [memex](../memex/), [mtk](../mtk/), [btk](../btk/), [ptk](../ptk/), [ebk](../ebk/), [repoindex](../repoindex/), [chartfold](../chartfold/) -- Source toolkits (producers of arkiv JSONL)
|
|
143
|
+
- [longecho](../longecho/) -- longecho compliance validator
|
arkiv-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alex Towell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
arkiv-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arkiv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Universal personal data format. JSONL in, SQL out, MCP to LLMs.
|
|
5
|
+
Project-URL: Homepage, https://github.com/queelius/arkiv
|
|
6
|
+
Project-URL: Repository, https://github.com/queelius/arkiv
|
|
7
|
+
Project-URL: Issues, https://github.com/queelius/arkiv/issues
|
|
8
|
+
Author-email: Alexander Towell <lex@metafunctor.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Database
|
|
21
|
+
Classifier: Topic :: System :: Archiving
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Requires-Dist: pyyaml>=6.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: black; extra == 'dev'
|
|
26
|
+
Requires-Dist: flake8; extra == 'dev'
|
|
27
|
+
Requires-Dist: mcp[cli]; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
31
|
+
Provides-Extra: mcp
|
|
32
|
+
Requires-Dist: mcp[cli]; extra == 'mcp'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# arkiv
|
|
36
|
+
|
|
37
|
+
Universal personal data format. JSONL in, SQL out, MCP to LLMs.
|
|
38
|
+
|
|
39
|
+
## The Format
|
|
40
|
+
|
|
41
|
+
Every record is a JSON object. All fields optional.
|
|
42
|
+
|
|
43
|
+
```jsonl
|
|
44
|
+
{"mimetype": "text/plain", "content": "I think the key insight is...", "uri": "https://chatgpt.com/c/abc", "timestamp": "2023-05-14T10:30:00Z", "metadata": {"role": "user", "conversation_id": "abc"}}
|
|
45
|
+
{"mimetype": "audio/wav", "uri": "file://media/podcast.wav", "timestamp": "2024-01-15", "metadata": {"transcript": "Welcome to...", "duration": 45.2}}
|
|
46
|
+
{"mimetype": "image/jpeg", "uri": "file://media/photo.jpg", "metadata": {"caption": "My talk at MIT"}}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## The Stack
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
JSONL files (canonical, portable, human-readable)
|
|
53
|
+
↓ arkiv import
|
|
54
|
+
SQLite database (queryable, efficient, standard SQL)
|
|
55
|
+
↓ arkiv mcp
|
|
56
|
+
MCP server (3 tools → any LLM)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install arkiv
|
|
63
|
+
|
|
64
|
+
# Import JSONL to SQLite
|
|
65
|
+
arkiv import conversations.jsonl --db archive.db
|
|
66
|
+
|
|
67
|
+
# Query
|
|
68
|
+
arkiv query archive.db "SELECT content FROM records WHERE metadata->>'role' = 'user' LIMIT 5"
|
|
69
|
+
|
|
70
|
+
# Serve to LLMs via MCP
|
|
71
|
+
arkiv mcp archive.db
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## MCP Tools
|
|
75
|
+
|
|
76
|
+
| Tool | Description |
|
|
77
|
+
|------|-------------|
|
|
78
|
+
| `get_manifest()` | What collections exist, their descriptions and schemas |
|
|
79
|
+
| `get_schema(collection?)` | What metadata keys can be queried |
|
|
80
|
+
| `sql_query(query)` | Run read-only SQL |
|
|
81
|
+
|
|
82
|
+
## Why
|
|
83
|
+
|
|
84
|
+
- Your data lives in silos (ChatGPT, email, bookmarks, photos, voice memos)
|
|
85
|
+
- Source toolkits (memex, mtk, btk, ptk, ebk) export it as JSONL
|
|
86
|
+
- arkiv gives you one format, one database, one query interface
|
|
87
|
+
- Any LLM can query it via MCP
|
|
88
|
+
- JSONL is human-readable and durable. SQLite is the most deployed database in history.
|
|
89
|
+
|
|
90
|
+
## Spec
|
|
91
|
+
|
|
92
|
+
See [SPEC.md](SPEC.md) for the full technical specification.
|
arkiv-0.1.0/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# arkiv
|
|
2
|
+
|
|
3
|
+
Universal personal data format. JSONL in, SQL out, MCP to LLMs.
|
|
4
|
+
|
|
5
|
+
## The Format
|
|
6
|
+
|
|
7
|
+
Every record is a JSON object. All fields optional.
|
|
8
|
+
|
|
9
|
+
```jsonl
|
|
10
|
+
{"mimetype": "text/plain", "content": "I think the key insight is...", "uri": "https://chatgpt.com/c/abc", "timestamp": "2023-05-14T10:30:00Z", "metadata": {"role": "user", "conversation_id": "abc"}}
|
|
11
|
+
{"mimetype": "audio/wav", "uri": "file://media/podcast.wav", "timestamp": "2024-01-15", "metadata": {"transcript": "Welcome to...", "duration": 45.2}}
|
|
12
|
+
{"mimetype": "image/jpeg", "uri": "file://media/photo.jpg", "metadata": {"caption": "My talk at MIT"}}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## The Stack
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
JSONL files (canonical, portable, human-readable)
|
|
19
|
+
↓ arkiv import
|
|
20
|
+
SQLite database (queryable, efficient, standard SQL)
|
|
21
|
+
↓ arkiv mcp
|
|
22
|
+
MCP server (3 tools → any LLM)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install arkiv
|
|
29
|
+
|
|
30
|
+
# Import JSONL to SQLite
|
|
31
|
+
arkiv import conversations.jsonl --db archive.db
|
|
32
|
+
|
|
33
|
+
# Query
|
|
34
|
+
arkiv query archive.db "SELECT content FROM records WHERE metadata->>'role' = 'user' LIMIT 5"
|
|
35
|
+
|
|
36
|
+
# Serve to LLMs via MCP
|
|
37
|
+
arkiv mcp archive.db
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## MCP Tools
|
|
41
|
+
|
|
42
|
+
| Tool | Description |
|
|
43
|
+
|------|-------------|
|
|
44
|
+
| `get_manifest()` | What collections exist, their descriptions and schemas |
|
|
45
|
+
| `get_schema(collection?)` | What metadata keys can be queried |
|
|
46
|
+
| `sql_query(query)` | Run read-only SQL |
|
|
47
|
+
|
|
48
|
+
## Why
|
|
49
|
+
|
|
50
|
+
- Your data lives in silos (ChatGPT, email, bookmarks, photos, voice memos)
|
|
51
|
+
- Source toolkits (memex, mtk, btk, ptk, ebk) export it as JSONL
|
|
52
|
+
- arkiv gives you one format, one database, one query interface
|
|
53
|
+
- Any LLM can query it via MCP
|
|
54
|
+
- JSONL is human-readable and durable. SQLite is the most deployed database in history.
|
|
55
|
+
|
|
56
|
+
## Spec
|
|
57
|
+
|
|
58
|
+
See [SPEC.md](SPEC.md) for the full technical specification.
|