open-cognition 0.1.1__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 (99) hide show
  1. open_cognition-0.1.1/.env.example +5 -0
  2. open_cognition-0.1.1/.github/workflows/create-tag.yml +42 -0
  3. open_cognition-0.1.1/.github/workflows/publish.yml +30 -0
  4. open_cognition-0.1.1/.gitignore +17 -0
  5. open_cognition-0.1.1/.python-version +1 -0
  6. open_cognition-0.1.1/PKG-INFO +206 -0
  7. open_cognition-0.1.1/README.md +191 -0
  8. open_cognition-0.1.1/SKILL.md +558 -0
  9. open_cognition-0.1.1/docker-compose.yml +11 -0
  10. open_cognition-0.1.1/docs/api.md +185 -0
  11. open_cognition-0.1.1/docs/architecture.md +130 -0
  12. open_cognition-0.1.1/docs/concepts.md +117 -0
  13. open_cognition-0.1.1/docs/mcp-tools.md +123 -0
  14. open_cognition-0.1.1/docs/sm2.md +148 -0
  15. open_cognition-0.1.1/main.py +8 -0
  16. open_cognition-0.1.1/migrations/001_create_tables.surrealql +43 -0
  17. open_cognition-0.1.1/migrations/001_create_tables_down.surrealql +5 -0
  18. open_cognition-0.1.1/migrations/002_create_indexes.surrealql +3 -0
  19. open_cognition-0.1.1/migrations/002_create_indexes_down.surrealql +3 -0
  20. open_cognition-0.1.1/migrations/003_create_relations.surrealql +9 -0
  21. open_cognition-0.1.1/migrations/003_create_relations_down.surrealql +3 -0
  22. open_cognition-0.1.1/migrations/004_create_session_log.surrealql +13 -0
  23. open_cognition-0.1.1/migrations/004_create_session_log_down.surrealql +1 -0
  24. open_cognition-0.1.1/migrations/005_create_doubt.surrealql +12 -0
  25. open_cognition-0.1.1/migrations/005_create_doubt_down.surrealql +1 -0
  26. open_cognition-0.1.1/pyproject.toml +31 -0
  27. open_cognition-0.1.1/run_mcp.py +8 -0
  28. open_cognition-0.1.1/src/open_cognition/__init__.py +1 -0
  29. open_cognition-0.1.1/src/open_cognition/cli.py +104 -0
  30. open_cognition-0.1.1/src/open_cognition/config.py +51 -0
  31. open_cognition-0.1.1/src/open_cognition/frontend/__init__.py +0 -0
  32. open_cognition-0.1.1/src/open_cognition/frontend/routes.py +315 -0
  33. open_cognition-0.1.1/src/open_cognition/frontend/templates/artifacts.html +53 -0
  34. open_cognition-0.1.1/src/open_cognition/frontend/templates/base.html +121 -0
  35. open_cognition-0.1.1/src/open_cognition/frontend/templates/dashboard.html +63 -0
  36. open_cognition-0.1.1/src/open_cognition/frontend/templates/doubt_new.html +36 -0
  37. open_cognition-0.1.1/src/open_cognition/frontend/templates/doubts.html +73 -0
  38. open_cognition-0.1.1/src/open_cognition/frontend/templates/partials/topics_list.html +29 -0
  39. open_cognition-0.1.1/src/open_cognition/frontend/templates/resources.html +52 -0
  40. open_cognition-0.1.1/src/open_cognition/frontend/templates/review.html +264 -0
  41. open_cognition-0.1.1/src/open_cognition/frontend/templates/struggling.html +44 -0
  42. open_cognition-0.1.1/src/open_cognition/frontend/templates/topic_detail.html +102 -0
  43. open_cognition-0.1.1/src/open_cognition/frontend/templates/topic_edit.html +45 -0
  44. open_cognition-0.1.1/src/open_cognition/frontend/templates/topics.html +77 -0
  45. open_cognition-0.1.1/src/open_cognition/main.py +47 -0
  46. open_cognition-0.1.1/src/open_cognition/mcp/__init__.py +0 -0
  47. open_cognition-0.1.1/src/open_cognition/mcp/server.py +33 -0
  48. open_cognition-0.1.1/src/open_cognition/mcp/tools/__init__.py +0 -0
  49. open_cognition-0.1.1/src/open_cognition/mcp/tools/artifact_tools.py +27 -0
  50. open_cognition-0.1.1/src/open_cognition/mcp/tools/doubt_tools.py +43 -0
  51. open_cognition-0.1.1/src/open_cognition/mcp/tools/flashcard_tools.py +96 -0
  52. open_cognition-0.1.1/src/open_cognition/mcp/tools/resource_tools.py +29 -0
  53. open_cognition-0.1.1/src/open_cognition/mcp/tools/session_tools.py +131 -0
  54. open_cognition-0.1.1/src/open_cognition/mcp/tools/topic_tools.py +54 -0
  55. open_cognition-0.1.1/src/open_cognition/migrations/001_create_tables.surrealql +43 -0
  56. open_cognition-0.1.1/src/open_cognition/migrations/001_create_tables_down.surrealql +5 -0
  57. open_cognition-0.1.1/src/open_cognition/migrations/002_create_indexes.surrealql +3 -0
  58. open_cognition-0.1.1/src/open_cognition/migrations/002_create_indexes_down.surrealql +3 -0
  59. open_cognition-0.1.1/src/open_cognition/migrations/003_create_relations.surrealql +9 -0
  60. open_cognition-0.1.1/src/open_cognition/migrations/003_create_relations_down.surrealql +3 -0
  61. open_cognition-0.1.1/src/open_cognition/migrations/004_create_session_log.surrealql +13 -0
  62. open_cognition-0.1.1/src/open_cognition/migrations/004_create_session_log_down.surrealql +1 -0
  63. open_cognition-0.1.1/src/open_cognition/migrations/005_create_doubt.surrealql +12 -0
  64. open_cognition-0.1.1/src/open_cognition/migrations/005_create_doubt_down.surrealql +1 -0
  65. open_cognition-0.1.1/src/open_cognition/models/__init__.py +0 -0
  66. open_cognition-0.1.1/src/open_cognition/models/artifact.py +33 -0
  67. open_cognition-0.1.1/src/open_cognition/models/doubt.py +25 -0
  68. open_cognition-0.1.1/src/open_cognition/models/flashcard.py +29 -0
  69. open_cognition-0.1.1/src/open_cognition/models/resource.py +28 -0
  70. open_cognition-0.1.1/src/open_cognition/models/review.py +28 -0
  71. open_cognition-0.1.1/src/open_cognition/models/session_log.py +26 -0
  72. open_cognition-0.1.1/src/open_cognition/models/topic.py +30 -0
  73. open_cognition-0.1.1/src/open_cognition/repositories/__init__.py +0 -0
  74. open_cognition-0.1.1/src/open_cognition/repositories/artifact_repo.py +45 -0
  75. open_cognition-0.1.1/src/open_cognition/repositories/doubt_repo.py +46 -0
  76. open_cognition-0.1.1/src/open_cognition/repositories/flashcard_repo.py +57 -0
  77. open_cognition-0.1.1/src/open_cognition/repositories/resource_repo.py +47 -0
  78. open_cognition-0.1.1/src/open_cognition/repositories/review_repo.py +31 -0
  79. open_cognition-0.1.1/src/open_cognition/repositories/session_log_repo.py +20 -0
  80. open_cognition-0.1.1/src/open_cognition/repositories/topic_repo.py +52 -0
  81. open_cognition-0.1.1/src/open_cognition/routes/__init__.py +0 -0
  82. open_cognition-0.1.1/src/open_cognition/routes/artifact_routes.py +25 -0
  83. open_cognition-0.1.1/src/open_cognition/routes/doubt_routes.py +24 -0
  84. open_cognition-0.1.1/src/open_cognition/routes/flashcard_routes.py +51 -0
  85. open_cognition-0.1.1/src/open_cognition/routes/resource_routes.py +25 -0
  86. open_cognition-0.1.1/src/open_cognition/routes/topic_routes.py +42 -0
  87. open_cognition-0.1.1/src/open_cognition/services/__init__.py +0 -0
  88. open_cognition-0.1.1/src/open_cognition/services/artifact_service.py +63 -0
  89. open_cognition-0.1.1/src/open_cognition/services/doubt_service.py +61 -0
  90. open_cognition-0.1.1/src/open_cognition/services/flashcard_service.py +56 -0
  91. open_cognition-0.1.1/src/open_cognition/services/resource_service.py +52 -0
  92. open_cognition-0.1.1/src/open_cognition/services/review_service.py +113 -0
  93. open_cognition-0.1.1/src/open_cognition/services/session_log_service.py +27 -0
  94. open_cognition-0.1.1/src/open_cognition/services/sm2_service.py +45 -0
  95. open_cognition-0.1.1/src/open_cognition/services/topic_service.py +62 -0
  96. open_cognition-0.1.1/src/open_cognition/utils.py +22 -0
  97. open_cognition-0.1.1/tests/__init__.py +0 -0
  98. open_cognition-0.1.1/tests/test_sm2.py +42 -0
  99. open_cognition-0.1.1/uv.lock +1875 -0
@@ -0,0 +1,5 @@
1
+ SURREAL_URL=ws://localhost:8000/rpc
2
+ SURREAL_USER=root
3
+ SURREAL_PASSWORD=root
4
+ SURREAL_NAMESPACE=open-cognition
5
+ SURREAL_DATABASE=test
@@ -0,0 +1,42 @@
1
+ name: Create Release Tag
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ confirm:
7
+ description: 'Type "yes" to confirm tag creation'
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ create-tag:
13
+ runs-on: ubuntu-latest
14
+ if: github.event.inputs.confirm == 'yes'
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - name: Extract version from pyproject.toml
22
+ id: version
23
+ run: |
24
+ VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
25
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
26
+ echo "tag=v$VERSION" >> $GITHUB_OUTPUT
27
+ echo "Detected version: $VERSION"
28
+
29
+ - name: Check if tag already exists
30
+ run: |
31
+ if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
32
+ echo "Tag ${{ steps.version.outputs.tag }} already exists!"
33
+ exit 1
34
+ fi
35
+
36
+ - name: Create and push tag
37
+ run: |
38
+ git config user.name "github-actions[bot]"
39
+ git config user.email "github-actions[bot]@users.noreply.github.com"
40
+ git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
41
+ git push origin "${{ steps.version.outputs.tag }}"
42
+ echo "Created and pushed tag ${{ steps.version.outputs.tag }}"
@@ -0,0 +1,30 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Setup Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.13"
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v4
23
+
24
+ - name: Build package
25
+ run: uv build
26
+
27
+ - name: Publish to PyPI
28
+ env:
29
+ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
30
+ run: uv publish --token "$PYPI_TOKEN"
@@ -0,0 +1,17 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Environment
13
+ .env
14
+
15
+ # Project docs (internal)
16
+ MVP.md
17
+ VISION.md
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: open-cognition
3
+ Version: 0.1.1
4
+ Summary: AI-powered learning system with spaced repetition
5
+ Requires-Python: >=3.13
6
+ Requires-Dist: fastapi
7
+ Requires-Dist: fastmcp
8
+ Requires-Dist: jinja2
9
+ Requires-Dist: loguru
10
+ Requires-Dist: pydantic
11
+ Requires-Dist: python-dotenv
12
+ Requires-Dist: surreal-basics>=0.3.0
13
+ Requires-Dist: uvicorn[standard]
14
+ Description-Content-Type: text/markdown
15
+
16
+ # open-cognition
17
+
18
+ AI-powered learning system with spaced repetition. Study with LLMs, capture knowledge, review with science-backed methods.
19
+
20
+ ## The Problem
21
+
22
+ When you study with AI (Claude, ChatGPT, etc.), the knowledge gets lost. You learn in one place, take notes in another, create flashcards in a third, and review in isolation. There's no system connecting the dots.
23
+
24
+ ## How it Works
25
+
26
+ open-cognition bridges the gap between AI-assisted learning and retention:
27
+
28
+ 1. **Study with your LLM** — Claude acts as your Socratic sparring partner via MCP
29
+ 2. **Capture outputs** — flashcards, summaries, resources, and artifacts are saved automatically
30
+ 3. **Organize in a knowledge graph** — topics and subtopics you control
31
+ 4. **Review with spaced repetition** — SM-2 algorithm (same foundation as Anki)
32
+ 5. **Deepen with Feynman technique** — structured sessions that identify and close knowledge gaps
33
+
34
+ ## Quick Start
35
+
36
+ ### Prerequisites
37
+
38
+ - Python 3.13+
39
+ - [uv](https://docs.astral.sh/uv/)
40
+
41
+ That's it. No database server required — open-cognition uses an embedded local database file by default. Your data stays on your machine.
42
+
43
+ ### Install and Run
44
+
45
+ ```bash
46
+ # Run directly (no clone needed)
47
+ uvx open-cognition serve
48
+ ```
49
+
50
+ Open http://localhost:8080 and start learning.
51
+
52
+ ### Using with Claude Desktop
53
+
54
+ This is where open-cognition shines. Connect it to Claude Desktop and get a learning partner that knows your knowledge graph.
55
+
56
+ #### 1. Set up the MCP Server
57
+
58
+ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "open-cognition": {
64
+ "command": "uvx",
65
+ "args": ["open-cognition", "mcp"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ That's it — `uvx` handles installation and dependencies automatically.
72
+
73
+ #### 2. Add the Skill
74
+
75
+ Download [SKILL.md](https://raw.githubusercontent.com/lfnovo/open-cognition/main/SKILL.md) and add it to your Claude Desktop skills, or include it in your project's `.claude/skills/` folder.
76
+
77
+ The skill instructs Claude to:
78
+ - Be a **Socratic sparring partner** during study sessions — not a lecturer
79
+ - Use the **Feynman technique** to identify and close knowledge gaps
80
+ - Create high-quality flashcards following strict rules (atomic, active recall, concise)
81
+ - Never create topics or cards without your approval
82
+ - Track your doubts and struggling cards
83
+
84
+ #### 3. Start Learning
85
+
86
+ Talk to Claude naturally:
87
+
88
+ - *"Let's study Transformers"* → starts a session, loads your existing knowledge
89
+ - *"Create flashcards from what we discussed"* → proposes cards for your approval
90
+ - *"Let's do a Feynman session on Attention"* → structured gap-finding protocol
91
+ - *"What doubts do I have open?"* → reviews pending questions
92
+ - *"Which cards am I struggling with?"* → identifies weak spots
93
+
94
+ ## Features
95
+
96
+ ### Web UI
97
+
98
+ - **Dashboard** — due cards count, struggling cards, quick actions
99
+ - **Topics** — create, edit, delete, hierarchical subtopics
100
+ - **Review session** — flashcard review with SM-2, quality buttons, progress tracking
101
+ - **Artifacts** — markdown + mermaid rendering in modal viewer
102
+ - **Resources** — links, PDFs, videos organized by topic
103
+ - **Doubts** — capture questions during review, work them later with the LLM
104
+ - **Struggling cards** — analytics on most-errored flashcards
105
+ - **Copyable IDs** — click any entity ID to copy (e.g., `topic:abc123`) for LLM reference
106
+
107
+ ### MCP Tools (18 tools)
108
+
109
+ | Category | Tools |
110
+ |----------|-------|
111
+ | Topics | get_topics, create_topic, update_topic, relate_topics |
112
+ | Flashcards | get_flashcards, get_due_flashcards, create_flashcard, create_flashcards_batch, review_flashcard, get_struggling_cards |
113
+ | Resources | get_resources, create_resource |
114
+ | Artifacts | get_artifacts, create_artifact |
115
+ | Doubts | get_doubts, create_doubt, resolve_doubt |
116
+ | Sessions | start_session, end_session, get_session_logs |
117
+
118
+ ### Spaced Repetition (SM-2)
119
+
120
+ The same algorithm behind Anki. Cards you answer correctly get longer intervals; cards you miss reset to 1 day. The ease factor adapts per card — easy cards space out faster, hard cards stay frequent.
121
+
122
+ See [docs/sm2.md](docs/sm2.md) for the full algorithm with formulas and examples.
123
+
124
+ ## Configuration
125
+
126
+ | Variable | Default | Description |
127
+ |----------|---------|-------------|
128
+ | `OC_HOST` | `0.0.0.0` | Web server host |
129
+ | `OC_PORT` | `8080` | Web server port |
130
+ | `OC_DATA_DIR` | `~/.open-cognition` | Data directory |
131
+ | `SURREAL_URL` | — | SurrealDB connection URL (optional — uses embedded DB if not set) |
132
+ | `SURREAL_USER` | `root` | SurrealDB username |
133
+ | `SURREAL_PASSWORD` | `root` | SurrealDB password |
134
+ | `SURREAL_NAMESPACE` | `open-cognition` | SurrealDB namespace |
135
+ | `SURREAL_DATABASE` | `test` | SurrealDB database |
136
+
137
+ You can set these in a `.env` file or as environment variables.
138
+
139
+ ### External SurrealDB (optional)
140
+
141
+ By default, open-cognition stores everything in a local file. If you prefer a standalone SurrealDB server (for multi-device access, backups, or production):
142
+
143
+ ```bash
144
+ # Via Docker
145
+ docker compose up -d
146
+
147
+ # Or point to your existing instance
148
+ export SURREAL_URL=ws://localhost:8000/rpc
149
+ ```
150
+
151
+ ## CLI
152
+
153
+ ```bash
154
+ uvx open-cognition serve [--host HOST] [--port PORT] # Start the web app
155
+ uvx open-cognition mcp # Start the MCP server
156
+ uvx open-cognition --version # Show version
157
+ uvx open-cognition --help # Show help
158
+ ```
159
+
160
+ ## Architecture
161
+
162
+ ```
163
+ Claude (LLM) ──► MCP Tools ──┐
164
+ ├──► Services ──► Repositories ──► SurrealDB
165
+ Web UI (HTMX) ──► API Routes ┘
166
+ ```
167
+
168
+ MCP tools and API routes share the same services layer. The LLM and the web UI see the same data.
169
+
170
+ See [docs/architecture.md](docs/architecture.md) for details.
171
+
172
+ ## Development
173
+
174
+ ```bash
175
+ git clone https://github.com/lfnovo/open-cognition.git
176
+ cd open-cognition
177
+ uv sync
178
+ open-cognition serve
179
+ ```
180
+
181
+ Run tests:
182
+ ```bash
183
+ uv run pytest
184
+ ```
185
+
186
+ ## Documentation
187
+
188
+ - [Architecture](docs/architecture.md) — layers, data model, graph relations
189
+ - [Concepts](docs/concepts.md) — topics, flashcards, resources, artifacts, sessions, doubts
190
+ - [SM-2 Algorithm](docs/sm2.md) — spaced repetition formulas and examples
191
+ - [API Reference](docs/api.md) — REST endpoints
192
+ - [MCP Tools](docs/mcp-tools.md) — tools for LLM integration
193
+
194
+ ## Stack
195
+
196
+ | Layer | Technology |
197
+ |-------|-----------|
198
+ | Backend | Python + FastAPI |
199
+ | Database | SurrealDB (embedded file or server) |
200
+ | Frontend | HTMX + Jinja2 + Tailwind CSS |
201
+ | MCP | FastMCP |
202
+ | LLM | Claude (via skill + MCP) |
203
+
204
+ ## License
205
+
206
+ MIT
@@ -0,0 +1,191 @@
1
+ # open-cognition
2
+
3
+ AI-powered learning system with spaced repetition. Study with LLMs, capture knowledge, review with science-backed methods.
4
+
5
+ ## The Problem
6
+
7
+ When you study with AI (Claude, ChatGPT, etc.), the knowledge gets lost. You learn in one place, take notes in another, create flashcards in a third, and review in isolation. There's no system connecting the dots.
8
+
9
+ ## How it Works
10
+
11
+ open-cognition bridges the gap between AI-assisted learning and retention:
12
+
13
+ 1. **Study with your LLM** — Claude acts as your Socratic sparring partner via MCP
14
+ 2. **Capture outputs** — flashcards, summaries, resources, and artifacts are saved automatically
15
+ 3. **Organize in a knowledge graph** — topics and subtopics you control
16
+ 4. **Review with spaced repetition** — SM-2 algorithm (same foundation as Anki)
17
+ 5. **Deepen with Feynman technique** — structured sessions that identify and close knowledge gaps
18
+
19
+ ## Quick Start
20
+
21
+ ### Prerequisites
22
+
23
+ - Python 3.13+
24
+ - [uv](https://docs.astral.sh/uv/)
25
+
26
+ That's it. No database server required — open-cognition uses an embedded local database file by default. Your data stays on your machine.
27
+
28
+ ### Install and Run
29
+
30
+ ```bash
31
+ # Run directly (no clone needed)
32
+ uvx open-cognition serve
33
+ ```
34
+
35
+ Open http://localhost:8080 and start learning.
36
+
37
+ ### Using with Claude Desktop
38
+
39
+ This is where open-cognition shines. Connect it to Claude Desktop and get a learning partner that knows your knowledge graph.
40
+
41
+ #### 1. Set up the MCP Server
42
+
43
+ Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "open-cognition": {
49
+ "command": "uvx",
50
+ "args": ["open-cognition", "mcp"]
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ That's it — `uvx` handles installation and dependencies automatically.
57
+
58
+ #### 2. Add the Skill
59
+
60
+ Download [SKILL.md](https://raw.githubusercontent.com/lfnovo/open-cognition/main/SKILL.md) and add it to your Claude Desktop skills, or include it in your project's `.claude/skills/` folder.
61
+
62
+ The skill instructs Claude to:
63
+ - Be a **Socratic sparring partner** during study sessions — not a lecturer
64
+ - Use the **Feynman technique** to identify and close knowledge gaps
65
+ - Create high-quality flashcards following strict rules (atomic, active recall, concise)
66
+ - Never create topics or cards without your approval
67
+ - Track your doubts and struggling cards
68
+
69
+ #### 3. Start Learning
70
+
71
+ Talk to Claude naturally:
72
+
73
+ - *"Let's study Transformers"* → starts a session, loads your existing knowledge
74
+ - *"Create flashcards from what we discussed"* → proposes cards for your approval
75
+ - *"Let's do a Feynman session on Attention"* → structured gap-finding protocol
76
+ - *"What doubts do I have open?"* → reviews pending questions
77
+ - *"Which cards am I struggling with?"* → identifies weak spots
78
+
79
+ ## Features
80
+
81
+ ### Web UI
82
+
83
+ - **Dashboard** — due cards count, struggling cards, quick actions
84
+ - **Topics** — create, edit, delete, hierarchical subtopics
85
+ - **Review session** — flashcard review with SM-2, quality buttons, progress tracking
86
+ - **Artifacts** — markdown + mermaid rendering in modal viewer
87
+ - **Resources** — links, PDFs, videos organized by topic
88
+ - **Doubts** — capture questions during review, work them later with the LLM
89
+ - **Struggling cards** — analytics on most-errored flashcards
90
+ - **Copyable IDs** — click any entity ID to copy (e.g., `topic:abc123`) for LLM reference
91
+
92
+ ### MCP Tools (18 tools)
93
+
94
+ | Category | Tools |
95
+ |----------|-------|
96
+ | Topics | get_topics, create_topic, update_topic, relate_topics |
97
+ | Flashcards | get_flashcards, get_due_flashcards, create_flashcard, create_flashcards_batch, review_flashcard, get_struggling_cards |
98
+ | Resources | get_resources, create_resource |
99
+ | Artifacts | get_artifacts, create_artifact |
100
+ | Doubts | get_doubts, create_doubt, resolve_doubt |
101
+ | Sessions | start_session, end_session, get_session_logs |
102
+
103
+ ### Spaced Repetition (SM-2)
104
+
105
+ The same algorithm behind Anki. Cards you answer correctly get longer intervals; cards you miss reset to 1 day. The ease factor adapts per card — easy cards space out faster, hard cards stay frequent.
106
+
107
+ See [docs/sm2.md](docs/sm2.md) for the full algorithm with formulas and examples.
108
+
109
+ ## Configuration
110
+
111
+ | Variable | Default | Description |
112
+ |----------|---------|-------------|
113
+ | `OC_HOST` | `0.0.0.0` | Web server host |
114
+ | `OC_PORT` | `8080` | Web server port |
115
+ | `OC_DATA_DIR` | `~/.open-cognition` | Data directory |
116
+ | `SURREAL_URL` | — | SurrealDB connection URL (optional — uses embedded DB if not set) |
117
+ | `SURREAL_USER` | `root` | SurrealDB username |
118
+ | `SURREAL_PASSWORD` | `root` | SurrealDB password |
119
+ | `SURREAL_NAMESPACE` | `open-cognition` | SurrealDB namespace |
120
+ | `SURREAL_DATABASE` | `test` | SurrealDB database |
121
+
122
+ You can set these in a `.env` file or as environment variables.
123
+
124
+ ### External SurrealDB (optional)
125
+
126
+ By default, open-cognition stores everything in a local file. If you prefer a standalone SurrealDB server (for multi-device access, backups, or production):
127
+
128
+ ```bash
129
+ # Via Docker
130
+ docker compose up -d
131
+
132
+ # Or point to your existing instance
133
+ export SURREAL_URL=ws://localhost:8000/rpc
134
+ ```
135
+
136
+ ## CLI
137
+
138
+ ```bash
139
+ uvx open-cognition serve [--host HOST] [--port PORT] # Start the web app
140
+ uvx open-cognition mcp # Start the MCP server
141
+ uvx open-cognition --version # Show version
142
+ uvx open-cognition --help # Show help
143
+ ```
144
+
145
+ ## Architecture
146
+
147
+ ```
148
+ Claude (LLM) ──► MCP Tools ──┐
149
+ ├──► Services ──► Repositories ──► SurrealDB
150
+ Web UI (HTMX) ──► API Routes ┘
151
+ ```
152
+
153
+ MCP tools and API routes share the same services layer. The LLM and the web UI see the same data.
154
+
155
+ See [docs/architecture.md](docs/architecture.md) for details.
156
+
157
+ ## Development
158
+
159
+ ```bash
160
+ git clone https://github.com/lfnovo/open-cognition.git
161
+ cd open-cognition
162
+ uv sync
163
+ open-cognition serve
164
+ ```
165
+
166
+ Run tests:
167
+ ```bash
168
+ uv run pytest
169
+ ```
170
+
171
+ ## Documentation
172
+
173
+ - [Architecture](docs/architecture.md) — layers, data model, graph relations
174
+ - [Concepts](docs/concepts.md) — topics, flashcards, resources, artifacts, sessions, doubts
175
+ - [SM-2 Algorithm](docs/sm2.md) — spaced repetition formulas and examples
176
+ - [API Reference](docs/api.md) — REST endpoints
177
+ - [MCP Tools](docs/mcp-tools.md) — tools for LLM integration
178
+
179
+ ## Stack
180
+
181
+ | Layer | Technology |
182
+ |-------|-----------|
183
+ | Backend | Python + FastAPI |
184
+ | Database | SurrealDB (embedded file or server) |
185
+ | Frontend | HTMX + Jinja2 + Tailwind CSS |
186
+ | MCP | FastMCP |
187
+ | LLM | Claude (via skill + MCP) |
188
+
189
+ ## License
190
+
191
+ MIT