codebase-cortex 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.
- codebase_cortex-0.1.0/.gitignore +24 -0
- codebase_cortex-0.1.0/LICENSE +21 -0
- codebase_cortex-0.1.0/PKG-INFO +209 -0
- codebase_cortex-0.1.0/README.md +163 -0
- codebase_cortex-0.1.0/docs/agents.md +299 -0
- codebase_cortex-0.1.0/docs/architecture.md +262 -0
- codebase_cortex-0.1.0/docs/cli-reference.md +313 -0
- codebase_cortex-0.1.0/docs/configuration.md +195 -0
- codebase_cortex-0.1.0/docs/contributing.md +239 -0
- codebase_cortex-0.1.0/docs/embeddings.md +242 -0
- codebase_cortex-0.1.0/docs/notion-integration.md +233 -0
- codebase_cortex-0.1.0/pyproject.toml +99 -0
- codebase_cortex-0.1.0/src/codebase_cortex/__init__.py +3 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/base.py +69 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/code_analyzer.py +122 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/doc_writer.py +356 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/semantic_finder.py +64 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/sprint_reporter.py +152 -0
- codebase_cortex-0.1.0/src/codebase_cortex/agents/task_creator.py +138 -0
- codebase_cortex-0.1.0/src/codebase_cortex/auth/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/auth/callback_server.py +80 -0
- codebase_cortex-0.1.0/src/codebase_cortex/auth/oauth.py +173 -0
- codebase_cortex-0.1.0/src/codebase_cortex/auth/token_store.py +90 -0
- codebase_cortex-0.1.0/src/codebase_cortex/cli.py +855 -0
- codebase_cortex-0.1.0/src/codebase_cortex/config.py +150 -0
- codebase_cortex-0.1.0/src/codebase_cortex/embeddings/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/embeddings/clustering.py +140 -0
- codebase_cortex-0.1.0/src/codebase_cortex/embeddings/indexer.py +208 -0
- codebase_cortex-0.1.0/src/codebase_cortex/embeddings/store.py +126 -0
- codebase_cortex-0.1.0/src/codebase_cortex/git/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/git/diff_parser.py +185 -0
- codebase_cortex-0.1.0/src/codebase_cortex/git/github_client.py +46 -0
- codebase_cortex-0.1.0/src/codebase_cortex/graph.py +111 -0
- codebase_cortex-0.1.0/src/codebase_cortex/mcp_client.py +94 -0
- codebase_cortex-0.1.0/src/codebase_cortex/notion/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/notion/bootstrap.py +298 -0
- codebase_cortex-0.1.0/src/codebase_cortex/notion/page_cache.py +107 -0
- codebase_cortex-0.1.0/src/codebase_cortex/state.py +77 -0
- codebase_cortex-0.1.0/src/codebase_cortex/utils/__init__.py +0 -0
- codebase_cortex-0.1.0/src/codebase_cortex/utils/json_parsing.py +59 -0
- codebase_cortex-0.1.0/src/codebase_cortex/utils/logging.py +62 -0
- codebase_cortex-0.1.0/src/codebase_cortex/utils/rate_limiter.py +56 -0
- codebase_cortex-0.1.0/src/codebase_cortex/utils/section_parser.py +139 -0
- codebase_cortex-0.1.0/tests/__init__.py +0 -0
- codebase_cortex-0.1.0/tests/conftest.py +50 -0
- codebase_cortex-0.1.0/tests/test_agents.py +199 -0
- codebase_cortex-0.1.0/tests/test_bootstrap.py +151 -0
- codebase_cortex-0.1.0/tests/test_config.py +102 -0
- codebase_cortex-0.1.0/tests/test_diff_parser.py +54 -0
- codebase_cortex-0.1.0/tests/test_embeddings.py +204 -0
- codebase_cortex-0.1.0/tests/test_graph.py +29 -0
- codebase_cortex-0.1.0/tests/test_page_cache.py +54 -0
- codebase_cortex-0.1.0/tests/test_section_parser.py +180 -0
- codebase_cortex-0.1.0/tests/test_state.py +27 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python
|
|
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
|
+
# Codebase Cortex per-repo data
|
|
16
|
+
.cortex/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.idea/
|
|
20
|
+
.vscode/
|
|
21
|
+
*.swp
|
|
22
|
+
|
|
23
|
+
# OS
|
|
24
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sarupuri Sai Lalith
|
|
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.
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codebase-cortex
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered documentation autopilot — commit code, docs update themselves. Five LangGraph agents analyze diffs, find related code via FAISS embeddings, and sync Notion pages through MCP.
|
|
5
|
+
Project-URL: Homepage, https://github.com/sarupurisailalith/codebase-cortex
|
|
6
|
+
Project-URL: Repository, https://github.com/sarupurisailalith/codebase-cortex
|
|
7
|
+
Project-URL: Documentation, https://github.com/sarupurisailalith/codebase-cortex/tree/main/docs
|
|
8
|
+
Project-URL: Issues, https://github.com/sarupurisailalith/codebase-cortex/issues
|
|
9
|
+
Author-email: Sailalith Sarupuri <sarupurisailalith@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,automation,code-analysis,developer-tools,docs-as-code,documentation,embeddings,faiss,git,langgraph,mcp,model-context-protocol,multi-agent,notion,semantic-search
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
26
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Requires-Dist: click>=8.0
|
|
30
|
+
Requires-Dist: faiss-cpu>=1.8
|
|
31
|
+
Requires-Dist: gitpython>=3.1
|
|
32
|
+
Requires-Dist: hdbscan>=0.8
|
|
33
|
+
Requires-Dist: httpx>=0.27
|
|
34
|
+
Requires-Dist: langchain-anthropic>=0.3
|
|
35
|
+
Requires-Dist: langchain-core>=0.3
|
|
36
|
+
Requires-Dist: langchain-google-genai>=2.1
|
|
37
|
+
Requires-Dist: langchain-mcp-adapters>=0.1
|
|
38
|
+
Requires-Dist: langchain-openai>=0.3
|
|
39
|
+
Requires-Dist: langgraph>=0.3
|
|
40
|
+
Requires-Dist: mcp>=1.0
|
|
41
|
+
Requires-Dist: pygithub>=2.0
|
|
42
|
+
Requires-Dist: python-dotenv>=1.0
|
|
43
|
+
Requires-Dist: rich>=13.0
|
|
44
|
+
Requires-Dist: sentence-transformers>=3.0
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Codebase Cortex
|
|
48
|
+
|
|
49
|
+
**Automatically keep your engineering documentation in sync with code.**
|
|
50
|
+
|
|
51
|
+
Codebase Cortex is a multi-agent system that watches your codebase for changes and updates your Notion documentation automatically. It uses LangGraph to orchestrate five specialized AI agents that analyze code, find related docs, write updates, create tasks, and generate sprint reports — all through the [Notion MCP](https://developers.notion.com/docs/mcp) protocol.
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
graph LR
|
|
55
|
+
A[Git Commit] --> B[CodeAnalyzer]
|
|
56
|
+
B --> C[SemanticFinder]
|
|
57
|
+
C --> D[DocWriter]
|
|
58
|
+
D --> E[TaskCreator]
|
|
59
|
+
E --> F[SprintReporter]
|
|
60
|
+
F --> G[Notion Workspace]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
|
|
65
|
+
- **Automatic doc sync** — Commit code, docs update themselves via post-commit hook
|
|
66
|
+
- **Section-level updates** — Only changed sections are rewritten, preserving the rest
|
|
67
|
+
- **Semantic search** — FAISS embeddings find related code across your entire codebase
|
|
68
|
+
- **Natural language prompts** — `cortex prompt "Add more API examples"` to direct updates
|
|
69
|
+
- **Multi-page intelligence** — Agents understand relationships across all your doc pages
|
|
70
|
+
- **Sprint reports** — Weekly summaries generated from commit activity
|
|
71
|
+
- **Task tracking** — Automatically identifies undocumented areas and creates Notion tasks
|
|
72
|
+
|
|
73
|
+
## Quick Start
|
|
74
|
+
|
|
75
|
+
### Prerequisites
|
|
76
|
+
|
|
77
|
+
- Python 3.11+
|
|
78
|
+
- [uv](https://docs.astral.sh/uv/) package manager
|
|
79
|
+
- A Notion account (free plan works)
|
|
80
|
+
- An LLM API key (Google Gemini, Anthropic, or OpenRouter)
|
|
81
|
+
|
|
82
|
+
### Install
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Install from PyPI
|
|
86
|
+
pip install codebase-cortex
|
|
87
|
+
|
|
88
|
+
# Or with uv
|
|
89
|
+
uv tool install codebase-cortex
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Both `cortex` and `codebase-cortex` commands are available after installation. If `cortex` conflicts with another package on your system, use `codebase-cortex` instead.
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary>Install from source</summary>
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
git clone https://github.com/sarupurisailalith/codebase-cortex.git
|
|
99
|
+
cd codebase-cortex
|
|
100
|
+
uv sync
|
|
101
|
+
uv tool install .
|
|
102
|
+
```
|
|
103
|
+
</details>
|
|
104
|
+
|
|
105
|
+
### Initialize in your project
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
cd /path/to/your-project
|
|
109
|
+
|
|
110
|
+
# Interactive setup — connects to Notion, configures LLM, creates starter pages
|
|
111
|
+
cortex init
|
|
112
|
+
|
|
113
|
+
# Run the pipeline
|
|
114
|
+
cortex run --once
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The `init` wizard will:
|
|
118
|
+
1. Ask for your LLM provider and API key
|
|
119
|
+
2. Open a browser for Notion OAuth authorization
|
|
120
|
+
3. Create starter documentation pages in Notion
|
|
121
|
+
4. Optionally install a post-commit git hook
|
|
122
|
+
|
|
123
|
+
## CLI Commands
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---------|-------------|
|
|
127
|
+
| `cortex init` | Interactive setup wizard |
|
|
128
|
+
| `cortex run --once` | Run the full pipeline once |
|
|
129
|
+
| `cortex run --once --full` | Full codebase analysis (not just recent diff) |
|
|
130
|
+
| `cortex run --once --dry-run` | Analyze without writing to Notion |
|
|
131
|
+
| `cortex prompt "instruction"` | Natural language doc updates |
|
|
132
|
+
| `cortex prompt "..." -p "Page"` | Target specific page(s) |
|
|
133
|
+
| `cortex status` | Show connection and config status |
|
|
134
|
+
| `cortex analyze` | One-shot diff analysis (no Notion writes) |
|
|
135
|
+
| `cortex embed` | Rebuild the FAISS embedding index |
|
|
136
|
+
| `cortex scan` | Discover existing Notion pages |
|
|
137
|
+
| `cortex scan --link <id>` | Link a specific Notion page |
|
|
138
|
+
|
|
139
|
+
## How It Works
|
|
140
|
+
|
|
141
|
+
Cortex creates a `.cortex/` directory (gitignored) in your project repo that stores configuration, OAuth tokens, and the FAISS vector index. When you run the pipeline, five agents work in sequence:
|
|
142
|
+
|
|
143
|
+
```mermaid
|
|
144
|
+
graph TD
|
|
145
|
+
START([Start]) --> CA[CodeAnalyzer]
|
|
146
|
+
CA -->|Has analysis?| SF[SemanticFinder]
|
|
147
|
+
CA -->|No changes| END1([End])
|
|
148
|
+
SF --> DW[DocWriter]
|
|
149
|
+
DW --> TC[TaskCreator]
|
|
150
|
+
TC -->|Has updates?| SR[SprintReporter]
|
|
151
|
+
TC -->|Nothing to report| END2([End])
|
|
152
|
+
SR --> END3([End])
|
|
153
|
+
|
|
154
|
+
style CA fill:#4A90D9,color:#fff
|
|
155
|
+
style SF fill:#7B68EE,color:#fff
|
|
156
|
+
style DW fill:#50C878,color:#fff
|
|
157
|
+
style TC fill:#FFB347,color:#fff
|
|
158
|
+
style SR fill:#FF6B6B,color:#fff
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
1. **CodeAnalyzer** — Parses git diffs (or scans the full codebase) and produces a structured analysis of what changed
|
|
162
|
+
2. **SemanticFinder** — Embeds the analysis and searches the FAISS index to find semantically related code chunks
|
|
163
|
+
3. **DocWriter** — Fetches current Notion pages, generates section-level updates, and merges them deterministically
|
|
164
|
+
4. **TaskCreator** — Identifies undocumented areas and creates task pages in Notion
|
|
165
|
+
5. **SprintReporter** — Synthesizes all activity into a weekly sprint summary
|
|
166
|
+
|
|
167
|
+
## Architecture
|
|
168
|
+
|
|
169
|
+
For detailed architecture documentation, see [`docs/architecture.md`](docs/architecture.md).
|
|
170
|
+
|
|
171
|
+
## Per-Repo Configuration
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
your-project/
|
|
175
|
+
├── .cortex/ # Created by cortex init (gitignored)
|
|
176
|
+
│ ├── .env # LLM provider, API keys
|
|
177
|
+
│ ├── .gitignore # Ignores everything in .cortex/
|
|
178
|
+
│ ├── notion_tokens.json # OAuth tokens (auto-refreshed)
|
|
179
|
+
│ ├── page_cache.json # Tracked Notion pages
|
|
180
|
+
│ └── faiss_index/ # Vector embeddings
|
|
181
|
+
│ ├── index.faiss
|
|
182
|
+
│ └── chunks.json
|
|
183
|
+
├── src/
|
|
184
|
+
└── ...
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Supported LLM Providers
|
|
188
|
+
|
|
189
|
+
| Provider | Models | Config Key |
|
|
190
|
+
|----------|--------|------------|
|
|
191
|
+
| Google Gemini | gemini-2.5-flash-lite, gemini-3-flash-preview, gemini-2.5-pro | `GOOGLE_API_KEY` |
|
|
192
|
+
| Anthropic | claude-sonnet-4, claude-haiku-4.5 | `ANTHROPIC_API_KEY` |
|
|
193
|
+
| OpenRouter | Any model via OpenRouter | `OPENROUTER_API_KEY` |
|
|
194
|
+
|
|
195
|
+
## Documentation
|
|
196
|
+
|
|
197
|
+
| Document | Description |
|
|
198
|
+
|----------|-------------|
|
|
199
|
+
| [Architecture](docs/architecture.md) | System design, data flow, agent pipeline |
|
|
200
|
+
| [CLI Reference](docs/cli-reference.md) | All commands, options, and examples |
|
|
201
|
+
| [Agents](docs/agents.md) | How each agent works |
|
|
202
|
+
| [Configuration](docs/configuration.md) | Setup, LLM providers, environment variables |
|
|
203
|
+
| [Notion Integration](docs/notion-integration.md) | OAuth flow, MCP protocol, page management |
|
|
204
|
+
| [Embeddings & Search](docs/embeddings.md) | FAISS index, semantic search, HDBSCAN clustering |
|
|
205
|
+
| [Contributing](docs/contributing.md) | Development setup, testing, project structure |
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Codebase Cortex
|
|
2
|
+
|
|
3
|
+
**Automatically keep your engineering documentation in sync with code.**
|
|
4
|
+
|
|
5
|
+
Codebase Cortex is a multi-agent system that watches your codebase for changes and updates your Notion documentation automatically. It uses LangGraph to orchestrate five specialized AI agents that analyze code, find related docs, write updates, create tasks, and generate sprint reports — all through the [Notion MCP](https://developers.notion.com/docs/mcp) protocol.
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
graph LR
|
|
9
|
+
A[Git Commit] --> B[CodeAnalyzer]
|
|
10
|
+
B --> C[SemanticFinder]
|
|
11
|
+
C --> D[DocWriter]
|
|
12
|
+
D --> E[TaskCreator]
|
|
13
|
+
E --> F[SprintReporter]
|
|
14
|
+
F --> G[Notion Workspace]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Automatic doc sync** — Commit code, docs update themselves via post-commit hook
|
|
20
|
+
- **Section-level updates** — Only changed sections are rewritten, preserving the rest
|
|
21
|
+
- **Semantic search** — FAISS embeddings find related code across your entire codebase
|
|
22
|
+
- **Natural language prompts** — `cortex prompt "Add more API examples"` to direct updates
|
|
23
|
+
- **Multi-page intelligence** — Agents understand relationships across all your doc pages
|
|
24
|
+
- **Sprint reports** — Weekly summaries generated from commit activity
|
|
25
|
+
- **Task tracking** — Automatically identifies undocumented areas and creates Notion tasks
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Prerequisites
|
|
30
|
+
|
|
31
|
+
- Python 3.11+
|
|
32
|
+
- [uv](https://docs.astral.sh/uv/) package manager
|
|
33
|
+
- A Notion account (free plan works)
|
|
34
|
+
- An LLM API key (Google Gemini, Anthropic, or OpenRouter)
|
|
35
|
+
|
|
36
|
+
### Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install from PyPI
|
|
40
|
+
pip install codebase-cortex
|
|
41
|
+
|
|
42
|
+
# Or with uv
|
|
43
|
+
uv tool install codebase-cortex
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Both `cortex` and `codebase-cortex` commands are available after installation. If `cortex` conflicts with another package on your system, use `codebase-cortex` instead.
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Install from source</summary>
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/sarupurisailalith/codebase-cortex.git
|
|
53
|
+
cd codebase-cortex
|
|
54
|
+
uv sync
|
|
55
|
+
uv tool install .
|
|
56
|
+
```
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
### Initialize in your project
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd /path/to/your-project
|
|
63
|
+
|
|
64
|
+
# Interactive setup — connects to Notion, configures LLM, creates starter pages
|
|
65
|
+
cortex init
|
|
66
|
+
|
|
67
|
+
# Run the pipeline
|
|
68
|
+
cortex run --once
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `init` wizard will:
|
|
72
|
+
1. Ask for your LLM provider and API key
|
|
73
|
+
2. Open a browser for Notion OAuth authorization
|
|
74
|
+
3. Create starter documentation pages in Notion
|
|
75
|
+
4. Optionally install a post-commit git hook
|
|
76
|
+
|
|
77
|
+
## CLI Commands
|
|
78
|
+
|
|
79
|
+
| Command | Description |
|
|
80
|
+
|---------|-------------|
|
|
81
|
+
| `cortex init` | Interactive setup wizard |
|
|
82
|
+
| `cortex run --once` | Run the full pipeline once |
|
|
83
|
+
| `cortex run --once --full` | Full codebase analysis (not just recent diff) |
|
|
84
|
+
| `cortex run --once --dry-run` | Analyze without writing to Notion |
|
|
85
|
+
| `cortex prompt "instruction"` | Natural language doc updates |
|
|
86
|
+
| `cortex prompt "..." -p "Page"` | Target specific page(s) |
|
|
87
|
+
| `cortex status` | Show connection and config status |
|
|
88
|
+
| `cortex analyze` | One-shot diff analysis (no Notion writes) |
|
|
89
|
+
| `cortex embed` | Rebuild the FAISS embedding index |
|
|
90
|
+
| `cortex scan` | Discover existing Notion pages |
|
|
91
|
+
| `cortex scan --link <id>` | Link a specific Notion page |
|
|
92
|
+
|
|
93
|
+
## How It Works
|
|
94
|
+
|
|
95
|
+
Cortex creates a `.cortex/` directory (gitignored) in your project repo that stores configuration, OAuth tokens, and the FAISS vector index. When you run the pipeline, five agents work in sequence:
|
|
96
|
+
|
|
97
|
+
```mermaid
|
|
98
|
+
graph TD
|
|
99
|
+
START([Start]) --> CA[CodeAnalyzer]
|
|
100
|
+
CA -->|Has analysis?| SF[SemanticFinder]
|
|
101
|
+
CA -->|No changes| END1([End])
|
|
102
|
+
SF --> DW[DocWriter]
|
|
103
|
+
DW --> TC[TaskCreator]
|
|
104
|
+
TC -->|Has updates?| SR[SprintReporter]
|
|
105
|
+
TC -->|Nothing to report| END2([End])
|
|
106
|
+
SR --> END3([End])
|
|
107
|
+
|
|
108
|
+
style CA fill:#4A90D9,color:#fff
|
|
109
|
+
style SF fill:#7B68EE,color:#fff
|
|
110
|
+
style DW fill:#50C878,color:#fff
|
|
111
|
+
style TC fill:#FFB347,color:#fff
|
|
112
|
+
style SR fill:#FF6B6B,color:#fff
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
1. **CodeAnalyzer** — Parses git diffs (or scans the full codebase) and produces a structured analysis of what changed
|
|
116
|
+
2. **SemanticFinder** — Embeds the analysis and searches the FAISS index to find semantically related code chunks
|
|
117
|
+
3. **DocWriter** — Fetches current Notion pages, generates section-level updates, and merges them deterministically
|
|
118
|
+
4. **TaskCreator** — Identifies undocumented areas and creates task pages in Notion
|
|
119
|
+
5. **SprintReporter** — Synthesizes all activity into a weekly sprint summary
|
|
120
|
+
|
|
121
|
+
## Architecture
|
|
122
|
+
|
|
123
|
+
For detailed architecture documentation, see [`docs/architecture.md`](docs/architecture.md).
|
|
124
|
+
|
|
125
|
+
## Per-Repo Configuration
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
your-project/
|
|
129
|
+
├── .cortex/ # Created by cortex init (gitignored)
|
|
130
|
+
│ ├── .env # LLM provider, API keys
|
|
131
|
+
│ ├── .gitignore # Ignores everything in .cortex/
|
|
132
|
+
│ ├── notion_tokens.json # OAuth tokens (auto-refreshed)
|
|
133
|
+
│ ├── page_cache.json # Tracked Notion pages
|
|
134
|
+
│ └── faiss_index/ # Vector embeddings
|
|
135
|
+
│ ├── index.faiss
|
|
136
|
+
│ └── chunks.json
|
|
137
|
+
├── src/
|
|
138
|
+
└── ...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Supported LLM Providers
|
|
142
|
+
|
|
143
|
+
| Provider | Models | Config Key |
|
|
144
|
+
|----------|--------|------------|
|
|
145
|
+
| Google Gemini | gemini-2.5-flash-lite, gemini-3-flash-preview, gemini-2.5-pro | `GOOGLE_API_KEY` |
|
|
146
|
+
| Anthropic | claude-sonnet-4, claude-haiku-4.5 | `ANTHROPIC_API_KEY` |
|
|
147
|
+
| OpenRouter | Any model via OpenRouter | `OPENROUTER_API_KEY` |
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
| Document | Description |
|
|
152
|
+
|----------|-------------|
|
|
153
|
+
| [Architecture](docs/architecture.md) | System design, data flow, agent pipeline |
|
|
154
|
+
| [CLI Reference](docs/cli-reference.md) | All commands, options, and examples |
|
|
155
|
+
| [Agents](docs/agents.md) | How each agent works |
|
|
156
|
+
| [Configuration](docs/configuration.md) | Setup, LLM providers, environment variables |
|
|
157
|
+
| [Notion Integration](docs/notion-integration.md) | OAuth flow, MCP protocol, page management |
|
|
158
|
+
| [Embeddings & Search](docs/embeddings.md) | FAISS index, semantic search, HDBSCAN clustering |
|
|
159
|
+
| [Contributing](docs/contributing.md) | Development setup, testing, project structure |
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|