own-your-code 0.1.3__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.
@@ -0,0 +1,26 @@
1
+ .venv/
2
+ venv/
3
+ __pycache__/
4
+ *.py[cod]
5
+ *.egg-info/
6
+ .eggs/
7
+ dist/
8
+ build/
9
+ .pytest_cache/
10
+ .coverage
11
+ htmlcov/
12
+
13
+ # Local SQLite (set OWN_YOUR_CODE_DB in production)
14
+ owns.db
15
+ *.db-journal
16
+
17
+ # Node / UI
18
+ ui/node_modules/
19
+ ui/dist/
20
+
21
+ # IDE / OS
22
+ .idea/
23
+ .vscode/
24
+ .DS_Store
25
+ .env
26
+ .env.*
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ksahoo
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,396 @@
1
+ Metadata-Version: 2.4
2
+ Name: own-your-code
3
+ Version: 0.1.3
4
+ Summary: Own Your Code — MCP server + UI: record why each function exists, tradeoffs, and evolution (SQLite)
5
+ Project-URL: Repository, https://github.com/khirodsahoo93/mcp-own-your-code
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: codebase,documentation,intent,mcp,sqlite
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: fastapi>=0.115.0
19
+ Requires-Dist: mcp>=1.0.0
20
+ Requires-Dist: pydantic>=2.0.0
21
+ Requires-Dist: uvicorn[standard]>=0.32.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: httpx>=0.27.0; extra == 'dev'
24
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
25
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
26
+ Provides-Extra: full
27
+ Requires-Dist: numpy>=1.26.0; extra == 'full'
28
+ Requires-Dist: sentence-transformers>=2.7.0; extra == 'full'
29
+ Requires-Dist: tree-sitter-go>=0.23.0; extra == 'full'
30
+ Requires-Dist: tree-sitter-javascript>=0.23.0; extra == 'full'
31
+ Requires-Dist: tree-sitter>=0.23.0; extra == 'full'
32
+ Provides-Extra: multilang
33
+ Requires-Dist: tree-sitter-go>=0.23.0; extra == 'multilang'
34
+ Requires-Dist: tree-sitter-javascript>=0.23.0; extra == 'multilang'
35
+ Requires-Dist: tree-sitter>=0.23.0; extra == 'multilang'
36
+ Provides-Extra: semantic
37
+ Requires-Dist: numpy>=1.26.0; extra == 'semantic'
38
+ Requires-Dist: sentence-transformers>=2.7.0; extra == 'semantic'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Own Your Code
42
+
43
+ **A living intent ledger for your codebase.**
44
+
45
+ Own Your Code captures the *why* behind every function — user requests, tradeoffs, decisions, and evolution — recorded via MCP as you work. Search by keyword or semantic similarity. Browse in a React UI or query the MCP server directly.
46
+
47
+ ---
48
+
49
+ ## The problem
50
+
51
+ Code is easy to read. It's impossible to understand.
52
+
53
+ You can read `hybrid_search()` in 5 minutes and know what it does. You can't know:
54
+ - Why cosine similarity instead of BM25?
55
+ - Was keyword-only search tried and rejected?
56
+ - What user request triggered this function?
57
+ - How did it behave before the last refactor?
58
+
59
+ That context lives in someone's head, a Slack thread, or nowhere.
60
+
61
+ **Own Your Code captures it at the moment it's created — while you’re implementing the change.**
62
+
63
+ ---
64
+
65
+ ## Features
66
+
67
+ - **Intent recording** — `record_intent` captures user request, reasoning, implementation notes, and confidence (typically from your MCP workflow).
68
+ - **Decision log** — tradeoffs, alternatives considered, constraints that forced a choice.
69
+ - **Evolution timeline** — every behavioral change with the reason and triggering request.
70
+ - **Multi-language AST indexing** — Python, TypeScript, JavaScript, Go. Pluggable extractor architecture.
71
+ - **Semantic search** — vector embeddings via `sentence-transformers`. Find `charge_card` by searching "what handles payments?".
72
+ - **Hybrid search** — merges keyword rank + semantic cosine score with tunable weight.
73
+ - **React UI** — Intent Map, Feature clusters, Search tab (keyword/semantic/hybrid), coverage bar, function detail panel.
74
+ - **MCP server** — works with any host that supports the Model Context Protocol.
75
+ - **FastAPI REST backend** — full API, suitable for team deployment.
76
+ - **Production-ready** — API key auth, SQLite WAL mode, configurable CORS, background embed jobs, 47 tests.
77
+
78
+ ---
79
+
80
+ ## Quick start
81
+
82
+ ### 1. Install (pick one)
83
+
84
+ **PyPI (after you publish, or use TestPyPI):**
85
+
86
+ ```bash
87
+ pipx install own-your-code # recommended — puts own-your-code-mcp on PATH
88
+ own-your-code install # merges MCP config (see platform IDs below)
89
+ ```
90
+
91
+ ```bash
92
+ python3 -m pip install own-your-code
93
+ own-your-code install --platform editor-a
94
+ own-your-code install --platform editor-b
95
+ ```
96
+
97
+ **npm (wrapper — still requires Python 3.11+ on PATH):**
98
+
99
+ ```bash
100
+ npx own-your-code-mcp install
101
+ ```
102
+
103
+ This runs `pip install -U own-your-code` if needed, then the same `own-your-code install` as above. Publish the shim from `npm/own-your-code-mcp/` to the npm registry when you are ready.
104
+
105
+ Use **`own-your-code-mcp` on PATH** (pipx/pip) for the actual MCP stdio server. The npm package is mainly so people who live in Node can run **`npx … install`** without memorizing pip; running MCP through `npx` is possible (`bin/mcp-shim.cjs`) but adds latency — prefer the Python binary when you can.
106
+
107
+ **From source:**
108
+
109
+ ```bash
110
+ git clone https://github.com/khirodsahoo93/mcp-own-your-code
111
+ cd mcp-own-your-code
112
+ python -m venv .venv && source .venv/bin/activate
113
+ pip install -e .
114
+
115
+ # With semantic search support
116
+ pip install -e ".[semantic]"
117
+
118
+ # With multi-language AST support (TypeScript, Go)
119
+ pip install -e ".[full]"
120
+ ```
121
+
122
+ Manual JSON fragment (if you skip `install`):
123
+
124
+ ```bash
125
+ own-your-code print-config
126
+ ```
127
+
128
+ **uv users:** if `own-your-code-mcp` is not on PATH but `uvx` is, `own-your-code install` writes a block that runs `uvx --from own-your-code own-your-code-mcp` (once the package is on PyPI).
129
+
130
+ **`own-your-code install --platform` IDs** — each maps to a known config location on disk (see `src/cli.py` for exact paths). Use `all` to update every configured location.
131
+
132
+ ### 2. Add to your MCP host
133
+
134
+ After `own-your-code install`, restart the editor. To configure by hand from a git checkout:
135
+
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "own-your-code": {
140
+ "command": "/path/to/.venv/bin/python",
141
+ "args": ["-m", "src.server"],
142
+ "cwd": "/path/to/mcp-own-your-code"
143
+ }
144
+ }
145
+ }
146
+ ```
147
+
148
+ Or if installed as a package:
149
+
150
+ ```json
151
+ {
152
+ "mcpServers": {
153
+ "own-your-code": {
154
+ "command": "own-your-code-mcp"
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ ### 3. Register your project
161
+
162
+ From your MCP client:
163
+
164
+ ```
165
+ register_project path="/path/to/your/project"
166
+ ```
167
+
168
+ This scans all Python, TypeScript, JavaScript, and Go files and indexes every function.
169
+
170
+ ### 4. Start building
171
+
172
+ As you write code, use `record_intent` from MCP (manually or via your host’s automation):
173
+
174
+ ```
175
+ record_intent
176
+ project_path="/path/to/your/project"
177
+ file="src/auth.py"
178
+ function_name="verify_token"
179
+ user_request="Add JWT verification so the API rejects unsigned requests"
180
+ reasoning="Using PyJWT with RS256. Chose asymmetric keys so the public key can be distributed to services without exposing the signing key."
181
+ decisions=[{"decision": "RS256 over HS256", "reason": "Asymmetric — services can verify without the secret", "alternatives": ["HS256"]}]
182
+ ```
183
+
184
+ ### 5. Open the UI
185
+
186
+ ```bash
187
+ uvicorn api.main:app --reload --port 8002
188
+ ```
189
+
190
+ Open [http://localhost:8002](http://localhost:8002).
191
+
192
+ ---
193
+
194
+ ## MCP tools
195
+
196
+ | Tool | Description |
197
+ |------|-------------|
198
+ | `register_project` | Scan and index a codebase (Python, TypeScript, JavaScript, Go) |
199
+ | `record_intent` | Record why a function exists — user request, reasoning, decisions |
200
+ | `record_evolution` | Log a behavioral change with the reason it happened |
201
+ | `explain_function` | Get the full story: intent, decisions, evolution timeline |
202
+ | `find_by_intent` | Search by keyword, semantic similarity, or hybrid |
203
+ | `embed_intents` | Backfill vector embeddings for semantic search |
204
+ | `get_codebase_map` | Full structured map: coverage, hook backlog, functions by file |
205
+ | `get_evolution` | Timeline of changes for a specific function |
206
+ | `annotate_existing` | Retroactively infer intents on a legacy codebase |
207
+ | `mark_file_reviewed` | Clear hook backlog for a file without adding intent |
208
+
209
+ ---
210
+
211
+ ## REST API
212
+
213
+ | Method | Endpoint | Description |
214
+ |--------|----------|-------------|
215
+ | `GET` | `/health` | Health check |
216
+ | `GET` | `/projects` | List registered projects |
217
+ | `POST` | `/register` | Register and index a project |
218
+ | `GET` | `/map` | Full codebase map (supports `?file=` filter) |
219
+ | `GET` | `/function` | Intent, decisions, evolution for one function |
220
+ | `POST` | `/search` | Search intents (keyword / semantic / hybrid) |
221
+ | `POST` | `/embed` | Start background embedding job (returns `job_id`) |
222
+ | `GET` | `/embed/{job_id}` | Poll embedding job status |
223
+ | `GET` | `/stats` | Coverage and hook backlog summary |
224
+ | `GET` | `/features` | Feature clusters |
225
+ | `GET` | `/graph` | ReactFlow-compatible node graph |
226
+
227
+ ---
228
+
229
+ ## Search modes
230
+
231
+ ```bash
232
+ # Keyword — fast LIKE search over intent text
233
+ find_by_intent project_path="..." query="authentication" mode="keyword"
234
+
235
+ # Semantic — vector cosine similarity (run embed_intents first)
236
+ find_by_intent project_path="..." query="what handles retries?" mode="semantic"
237
+
238
+ # Hybrid — merges keyword rank + semantic score
239
+ find_by_intent project_path="..." query="payment processing" mode="hybrid" semantic_weight=0.6
240
+ ```
241
+
242
+ Via REST:
243
+
244
+ ```bash
245
+ curl -X POST http://localhost:8002/search \
246
+ -H "Content-Type: application/json" \
247
+ -d '{"project_path": "/my/project", "query": "what handles payments?", "mode": "hybrid"}'
248
+ ```
249
+
250
+ ---
251
+
252
+ ## Multi-language support
253
+
254
+ | Language | Parser | Fallback |
255
+ |----------|--------|---------|
256
+ | Python | `ast` (stdlib) | — |
257
+ | TypeScript / JavaScript | `tree-sitter-javascript` | regex |
258
+ | Go | `tree-sitter-go` | regex |
259
+
260
+ Configure indexing:
261
+
262
+ ```json
263
+ {
264
+ "path": "/my/project",
265
+ "languages": ["python", "typescript"],
266
+ "include_globs": ["src/**/*.ts", "src/**/*.py"],
267
+ "ignore_dirs": ["vendor", "generated"]
268
+ }
269
+ ```
270
+
271
+ ---
272
+
273
+ ## Production deployment
274
+
275
+ ### Environment variables
276
+
277
+ | Variable | Default | Description |
278
+ |----------|---------|-------------|
279
+ | `OWN_YOUR_CODE_DB` | `owns.db` | Path to SQLite file |
280
+ | `OWN_YOUR_CODE_API_KEY` | *(unset)* | Require `X-Api-Key` header. Leave unset for local use. |
281
+ | `OWN_YOUR_CODE_CORS_ORIGINS` | `*` | Comma-separated allowed origins |
282
+ | `OWN_YOUR_CODE_EMBED_MODEL` | `all-MiniLM-L6-v2` | Sentence-transformers model name |
283
+
284
+ ### Docker
285
+
286
+ ```bash
287
+ docker compose up
288
+ ```
289
+
290
+ Or standalone:
291
+
292
+ ```bash
293
+ docker build -t own-your-code .
294
+ docker run -p 8002:8002 \
295
+ -e OWN_YOUR_CODE_API_KEY=your-secret \
296
+ -e OWN_YOUR_CODE_CORS_ORIGINS=https://yourapp.com \
297
+ -v $(pwd)/data:/data \
298
+ -e OWN_YOUR_CODE_DB=/data/owns.db \
299
+ own-your-code
300
+ ```
301
+
302
+ ### Render / Fly.io
303
+
304
+ A `render.yaml` is included. Set `OWN_YOUR_CODE_API_KEY` and `OWN_YOUR_CODE_DB` as environment variables in your deployment dashboard.
305
+
306
+ ---
307
+
308
+ ## Post-write hook
309
+
310
+ The post-write hook fires when your editor saves a file and records it in the backlog. Any file written without a subsequent `record_intent` appears in `get_codebase_map` as pending.
311
+
312
+ ```bash
313
+ # Install the hook script for non-pip use
314
+ cp hooks/post_write.py .git/hooks/post-write && chmod +x .git/hooks/post-write
315
+
316
+ # Or use the installed entry point
317
+ own-your-code-hook
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Development
323
+
324
+ ```bash
325
+ # Install dev dependencies
326
+ pip install -e ".[dev,full]"
327
+
328
+ # Run tests
329
+ pytest
330
+
331
+ # Lint
332
+ ruff check src/ api/ tests/
333
+
334
+ # Build UI
335
+ cd ui && npm install && npm run build
336
+ ```
337
+
338
+ CI runs on Python 3.11, 3.12, and 3.13.
339
+
340
+ ---
341
+
342
+ ## Schema
343
+
344
+ SQLite. Tables:
345
+
346
+ | Table | Purpose |
347
+ |-------|---------|
348
+ | `projects` | Registered codebase roots |
349
+ | `functions` | Every known function (AST-extracted) |
350
+ | `intents` | Why a function exists — user request, reasoning, confidence |
351
+ | `intent_embeddings` | Vector blobs for semantic search (schema v2) |
352
+ | `decisions` | Tradeoffs and alternatives considered |
353
+ | `evolution` | Timeline of behavioral changes |
354
+ | `features` | High-level feature labels |
355
+ | `feature_links` | Many-to-many: functions ↔ features |
356
+ | `hook_events` | Files written by editor but not yet annotated |
357
+
358
+ Schema version tracked via `PRAGMA user_version`. Migrations are safe to run on existing databases.
359
+
360
+ ---
361
+
362
+ ## Publishing (maintainers)
363
+
364
+ ### One-time setup
365
+
366
+ 1. **PyPI** — Create the project `own-your-code` on [pypi.org](https://pypi.org). Under **Manage → Publishing**, add a **trusted publisher** for this GitHub repo and workflow **`.github/workflows/release.yml`** (see [PyPI docs](https://docs.pypi.org/trusted-publishers/)).
367
+ 2. **npm** — Log in locally (`npm login`) once, or create a granular **Automation** token and add it as the GitHub secret **`NPM_TOKEN`** for this repository.
368
+
369
+ ### Automated (recommended)
370
+
371
+ Push a **semver tag** after bumping `version` in `pyproject.toml` and `npm/own-your-code-mcp/package.json`:
372
+
373
+ ```bash
374
+ # bump versions first, commit, then:
375
+ git tag v0.1.0
376
+ git push origin main && git push origin v0.1.0
377
+ ```
378
+
379
+ GitHub Actions **Release** workflow uploads the wheel + sdist to **PyPI** and publishes **`own-your-code-mcp`** to npm.
380
+
381
+ ### Manual
382
+
383
+ ```bash
384
+ python3 -m pip install build twine
385
+ python3 -m build
386
+ TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-YOUR_PYPI_API_TOKEN python3 -m twine upload dist/*
387
+ ```
388
+
389
+ ```bash
390
+ cd npm/own-your-code-mcp
391
+ npm publish --access public
392
+ ```
393
+
394
+ ## License
395
+
396
+ MIT