oneport-context 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.
- oneport_context-0.1.0/.gitignore +42 -0
- oneport_context-0.1.0/LICENSE +179 -0
- oneport_context-0.1.0/PKG-INFO +110 -0
- oneport_context-0.1.0/README.md +74 -0
- oneport_context-0.1.0/pyproject.toml +52 -0
- oneport_context-0.1.0/src/oneport_context/__init__.py +12 -0
- oneport_context-0.1.0/src/oneport_context/chat/__init__.py +6 -0
- oneport_context-0.1.0/src/oneport_context/chat/engine.py +69 -0
- oneport_context-0.1.0/src/oneport_context/cli.py +299 -0
- oneport_context-0.1.0/src/oneport_context/demo/__init__.py +6 -0
- oneport_context-0.1.0/src/oneport_context/demo/runner.py +21 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/README.md +9 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/api/routes.py +28 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/db/repository.py +29 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/main.py +13 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/models/task.py +19 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/models/user.py +9 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/services/task_service.py +18 -0
- oneport_context-0.1.0/src/oneport_context/demo/sample_repo/services/user_service.py +13 -0
- oneport_context-0.1.0/src/oneport_context/indexer.py +181 -0
- oneport_context-0.1.0/src/oneport_context/lsp/__init__.py +3 -0
- oneport_context-0.1.0/src/oneport_context/lsp/hover.py +78 -0
- oneport_context-0.1.0/src/oneport_context/lsp/server.py +63 -0
- oneport_context-0.1.0/src/oneport_context/models.py +110 -0
- oneport_context-0.1.0/src/oneport_context/pdf/__init__.py +7 -0
- oneport_context-0.1.0/src/oneport_context/pdf/builder.py +143 -0
- oneport_context-0.1.0/src/oneport_context/pdf/content.py +67 -0
- oneport_context-0.1.0/src/oneport_context/pdf/server.py +54 -0
- oneport_context-0.1.0/src/oneport_context/py.typed +1 -0
- oneport_context-0.1.0/src/oneport_context/show/__init__.py +6 -0
- oneport_context-0.1.0/src/oneport_context/show/server.py +53 -0
- oneport_context-0.1.0/src/oneport_context/show/template.py +207 -0
- oneport_context-0.1.0/src/oneport_context/storyboard.py +91 -0
- oneport_context-0.1.0/src/oneport_context/video/__init__.py +6 -0
- oneport_context-0.1.0/src/oneport_context/video/plan.py +60 -0
- oneport_context-0.1.0/src/oneport_context/video/render.py +71 -0
- oneport_context-0.1.0/src/oneport_context/video/runner.py +70 -0
- oneport_context-0.1.0/src/oneport_context/video/script.py +46 -0
- oneport_context-0.1.0/src/oneport_context/video/slides.py +123 -0
- oneport_context-0.1.0/src/oneport_context/video/tts.py +124 -0
- oneport_context-0.1.0/src/oneport_context/walker.py +211 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Secrets — NEVER commit
|
|
2
|
+
.env
|
|
3
|
+
.env.*
|
|
4
|
+
*.pem
|
|
5
|
+
audit.jsonl
|
|
6
|
+
|
|
7
|
+
# Python
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
build/
|
|
13
|
+
dist/
|
|
14
|
+
*.whl
|
|
15
|
+
*.tar.gz
|
|
16
|
+
|
|
17
|
+
# Virtual envs
|
|
18
|
+
.venv/
|
|
19
|
+
venv/
|
|
20
|
+
env/
|
|
21
|
+
|
|
22
|
+
# Test / tooling caches
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.ruff_cache/
|
|
26
|
+
.coverage
|
|
27
|
+
htmlcov/
|
|
28
|
+
|
|
29
|
+
# Editor / OS
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
34
|
+
|
|
35
|
+
# Generated caches & outputs
|
|
36
|
+
.context/
|
|
37
|
+
*.mp4
|
|
38
|
+
.history/
|
|
39
|
+
|
|
40
|
+
# Heap dumps & scratch (generated by demos / testing)
|
|
41
|
+
*.hprof
|
|
42
|
+
*.heapsnapshot
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works.
|
|
111
|
+
|
|
112
|
+
You may add Your own copyright statement to Your modifications and
|
|
113
|
+
may provide additional or different license terms and conditions
|
|
114
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
+
the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
+
this License, without any additional terms or conditions.
|
|
123
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
+
the terms of any separate license agreement you may have executed
|
|
125
|
+
with Licensor regarding such Contributions.
|
|
126
|
+
|
|
127
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
+
except as required for reasonable and customary use in describing the
|
|
130
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
+
|
|
132
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
+
implied, including, without limitation, any warranties or conditions
|
|
137
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
+
appropriateness of using or redistributing the Work and assume any
|
|
140
|
+
risks associated with Your exercise of permissions under this License.
|
|
141
|
+
|
|
142
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
+
unless required by applicable law (such as deliberate and grossly
|
|
145
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
+
liable to You for damages, including any direct, indirect, special,
|
|
147
|
+
incidental, or consequential damages of any character arising as a
|
|
148
|
+
result of this License or out of the use or inability to use the
|
|
149
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
+
other commercial damages or losses), even if such Contributor
|
|
152
|
+
has been advised of the possibility of such damages.
|
|
153
|
+
|
|
154
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
+
or other liability obligations and/or rights consistent with this
|
|
158
|
+
License. However, in accepting such obligations, You may act only
|
|
159
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
+
defend, and hold each Contributor harmless for any liability
|
|
162
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
+
of your accepting any such warranty or additional liability.
|
|
164
|
+
|
|
165
|
+
END OF TERMS AND CONDITIONS
|
|
166
|
+
|
|
167
|
+
Copyright 2024 OnePort Contributors
|
|
168
|
+
|
|
169
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
170
|
+
you may not use this file except in compliance with the License.
|
|
171
|
+
You may obtain a copy of the License at
|
|
172
|
+
|
|
173
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
174
|
+
|
|
175
|
+
Unless required by applicable law or agreed to in writing, software
|
|
176
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
177
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
178
|
+
See the License for the specific language governing permissions and
|
|
179
|
+
limitations under the License.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oneport-context
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Code Contextualizer — point it at any repo (no upload) and get a narrated architecture walkthrough, a handbook, and hover-to-explain in your editor. Runs locally on your own key.
|
|
5
|
+
Project-URL: Homepage, https://github.com/oneport-debug/oneport-context
|
|
6
|
+
Project-URL: Repository, https://github.com/oneport-debug/oneport-context
|
|
7
|
+
Author: OnePort Contributors
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: code-explanation,codebase,developer-tools,documentation,lsp,notebooklm,onboarding,walkthrough
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: click>=8.1.7
|
|
22
|
+
Requires-Dist: oneport-debug-core>=0.1.0
|
|
23
|
+
Requires-Dist: pydantic>=2.9.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
25
|
+
Requires-Dist: rich>=13.8.0
|
|
26
|
+
Provides-Extra: lsp
|
|
27
|
+
Requires-Dist: pygls>=1.3.0; extra == 'lsp'
|
|
28
|
+
Provides-Extra: pdf
|
|
29
|
+
Requires-Dist: reportlab>=4.0.0; extra == 'pdf'
|
|
30
|
+
Provides-Extra: video
|
|
31
|
+
Requires-Dist: gtts>=2.5.0; extra == 'video'
|
|
32
|
+
Requires-Dist: moviepy>=2.0.0; extra == 'video'
|
|
33
|
+
Requires-Dist: pillow>=10.0.0; extra == 'video'
|
|
34
|
+
Requires-Dist: pyttsx3>=2.90; extra == 'video'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# oneport-context
|
|
38
|
+
|
|
39
|
+
**Code Contextualizer — NotebookLM for your codebase, that never leaves your machine.**
|
|
40
|
+
|
|
41
|
+
Point it at any repo (however large — no upload) and it builds a hierarchical
|
|
42
|
+
understanding locally, then turns it into a **narrated architecture walkthrough**, a
|
|
43
|
+
**narrated MP4 video**, a **PDF handbook**, a **chat** that knows your code, and
|
|
44
|
+
**hover-to-explain** in your editor. Runs on your own model key (Google Gemini free
|
|
45
|
+
tier) or fully local — your code never leaves the machine.
|
|
46
|
+
|
|
47
|
+
## Try it in 60 seconds (no setup)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install oneport-context
|
|
51
|
+
oneport-context demo
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Opens a narrated, animated walkthrough of a bundled sample repo in your browser — no
|
|
55
|
+
API key needed.
|
|
56
|
+
|
|
57
|
+
## Use it on your own repo
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
export GEMINI_API_KEY=… # free key at aistudio.google.com/apikey
|
|
61
|
+
|
|
62
|
+
oneport-context index ./my-repo # build the understanding (cached in .context/)
|
|
63
|
+
oneport-context show ./my-repo # narrated walkthrough in the browser
|
|
64
|
+
oneport-context video ./my-repo # narrated MP4 (>= 8 min) -> needs [video]
|
|
65
|
+
oneport-context pdf ./my-repo # PDF handbook, opens in browser -> needs [pdf]
|
|
66
|
+
oneport-context chat ./my-repo # ask questions in the terminal
|
|
67
|
+
oneport-context lsp ./my-repo # editor hover-to-explain -> needs [lsp]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Without a key it still works in **heuristic mode** (structure + docstrings) — free and
|
|
71
|
+
offline, just less prose.
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
| Command | What it does | Extra |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `demo` | Zero-config narrated walkthrough of a bundled repo | — |
|
|
78
|
+
| `index ./repo` | Build the hierarchical understanding (cached) | — |
|
|
79
|
+
| `show ./repo` | Localhost narrated architecture walkthrough | — |
|
|
80
|
+
| `video ./repo` | Narrated MP4 (`--minutes`, `--voice`) | `[video]` |
|
|
81
|
+
| `pdf ./repo` | Styled PDF handbook, served in the browser | `[pdf]` |
|
|
82
|
+
| `chat ./repo` | Terminal Q&A grounded in your code | — |
|
|
83
|
+
| `lsp ./repo` | Hover-to-explain Language Server (VS Code / Neovim / JetBrains) | `[lsp]` |
|
|
84
|
+
|
|
85
|
+
## Install with the features you want
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install 'oneport-context[video,pdf,lsp]'
|
|
89
|
+
```
|
|
90
|
+
- `[video]` — pillow, moviepy (ffmpeg), gTTS voice
|
|
91
|
+
- `[pdf]` — reportlab
|
|
92
|
+
- `[lsp]` — pygls
|
|
93
|
+
|
|
94
|
+
## Why CLI, not upload
|
|
95
|
+
|
|
96
|
+
Big repos don't fit an upload box. The CLI walks the tree locally and builds a
|
|
97
|
+
**file -> module -> repo** summary (module summaries are batched, so a large repo
|
|
98
|
+
costs only a handful of model calls). Everything is cached in `.context/`; your code
|
|
99
|
+
never leaves the machine.
|
|
100
|
+
|
|
101
|
+
## Notes
|
|
102
|
+
|
|
103
|
+
- `video`/`pdf`/`chat` produce their best output with `GEMINI_API_KEY` set; heuristic
|
|
104
|
+
mode works without it.
|
|
105
|
+
- Prefer local/air-gapped? Set `ONEPORT_MODE=local` and run against Ollama.
|
|
106
|
+
- Have an Anthropic key? Set `ANTHROPIC_API_KEY` and it takes priority automatically.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache-2.0
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# oneport-context
|
|
2
|
+
|
|
3
|
+
**Code Contextualizer — NotebookLM for your codebase, that never leaves your machine.**
|
|
4
|
+
|
|
5
|
+
Point it at any repo (however large — no upload) and it builds a hierarchical
|
|
6
|
+
understanding locally, then turns it into a **narrated architecture walkthrough**, a
|
|
7
|
+
**narrated MP4 video**, a **PDF handbook**, a **chat** that knows your code, and
|
|
8
|
+
**hover-to-explain** in your editor. Runs on your own model key (Google Gemini free
|
|
9
|
+
tier) or fully local — your code never leaves the machine.
|
|
10
|
+
|
|
11
|
+
## Try it in 60 seconds (no setup)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install oneport-context
|
|
15
|
+
oneport-context demo
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Opens a narrated, animated walkthrough of a bundled sample repo in your browser — no
|
|
19
|
+
API key needed.
|
|
20
|
+
|
|
21
|
+
## Use it on your own repo
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export GEMINI_API_KEY=… # free key at aistudio.google.com/apikey
|
|
25
|
+
|
|
26
|
+
oneport-context index ./my-repo # build the understanding (cached in .context/)
|
|
27
|
+
oneport-context show ./my-repo # narrated walkthrough in the browser
|
|
28
|
+
oneport-context video ./my-repo # narrated MP4 (>= 8 min) -> needs [video]
|
|
29
|
+
oneport-context pdf ./my-repo # PDF handbook, opens in browser -> needs [pdf]
|
|
30
|
+
oneport-context chat ./my-repo # ask questions in the terminal
|
|
31
|
+
oneport-context lsp ./my-repo # editor hover-to-explain -> needs [lsp]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Without a key it still works in **heuristic mode** (structure + docstrings) — free and
|
|
35
|
+
offline, just less prose.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
| Command | What it does | Extra |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `demo` | Zero-config narrated walkthrough of a bundled repo | — |
|
|
42
|
+
| `index ./repo` | Build the hierarchical understanding (cached) | — |
|
|
43
|
+
| `show ./repo` | Localhost narrated architecture walkthrough | — |
|
|
44
|
+
| `video ./repo` | Narrated MP4 (`--minutes`, `--voice`) | `[video]` |
|
|
45
|
+
| `pdf ./repo` | Styled PDF handbook, served in the browser | `[pdf]` |
|
|
46
|
+
| `chat ./repo` | Terminal Q&A grounded in your code | — |
|
|
47
|
+
| `lsp ./repo` | Hover-to-explain Language Server (VS Code / Neovim / JetBrains) | `[lsp]` |
|
|
48
|
+
|
|
49
|
+
## Install with the features you want
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install 'oneport-context[video,pdf,lsp]'
|
|
53
|
+
```
|
|
54
|
+
- `[video]` — pillow, moviepy (ffmpeg), gTTS voice
|
|
55
|
+
- `[pdf]` — reportlab
|
|
56
|
+
- `[lsp]` — pygls
|
|
57
|
+
|
|
58
|
+
## Why CLI, not upload
|
|
59
|
+
|
|
60
|
+
Big repos don't fit an upload box. The CLI walks the tree locally and builds a
|
|
61
|
+
**file -> module -> repo** summary (module summaries are batched, so a large repo
|
|
62
|
+
costs only a handful of model calls). Everything is cached in `.context/`; your code
|
|
63
|
+
never leaves the machine.
|
|
64
|
+
|
|
65
|
+
## Notes
|
|
66
|
+
|
|
67
|
+
- `video`/`pdf`/`chat` produce their best output with `GEMINI_API_KEY` set; heuristic
|
|
68
|
+
mode works without it.
|
|
69
|
+
- Prefer local/air-gapped? Set `ONEPORT_MODE=local` and run against Ollama.
|
|
70
|
+
- Have an Anthropic key? Set `ANTHROPIC_API_KEY` and it takes priority automatically.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
Apache-2.0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "oneport-context"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Code Contextualizer — point it at any repo (no upload) and get a narrated architecture walkthrough, a handbook, and hover-to-explain in your editor. Runs locally on your own key."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Apache-2.0" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [{ name = "OnePort Contributors" }]
|
|
13
|
+
keywords = ["code-explanation", "onboarding", "documentation", "codebase", "walkthrough", "lsp", "notebooklm", "developer-tools"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: Apache Software License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Software Development :: Documentation",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"oneport-debug-core>=0.1.0",
|
|
27
|
+
"click>=8.1.7",
|
|
28
|
+
"rich>=13.8.0",
|
|
29
|
+
"pydantic>=2.9.0",
|
|
30
|
+
"PyYAML>=6.0.2",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
# Editor hover-to-explain via the Language Server Protocol.
|
|
35
|
+
lsp = ["pygls>=1.3.0"]
|
|
36
|
+
# Render a narrated MP4 walkthrough (slides + Gemini voice + video stitch).
|
|
37
|
+
video = ["pillow>=10.0.0", "moviepy>=2.0.0", "gTTS>=2.5.0", "pyttsx3>=2.90"]
|
|
38
|
+
# Generate a styled PDF handbook.
|
|
39
|
+
pdf = ["reportlab>=4.0.0"]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/oneport-debug/oneport-context"
|
|
43
|
+
Repository = "https://github.com/oneport-debug/oneport-context"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
oneport-context = "oneport_context.cli:main"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/oneport_context"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = ["src/oneport_context", "README.md"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 OnePort Contributors
|
|
3
|
+
"""
|
|
4
|
+
oneport-context — Code Contextualizer.
|
|
5
|
+
|
|
6
|
+
Point it at any repo (however large, no upload) and it builds a hierarchical
|
|
7
|
+
understanding on your machine, then turns it into a narrated architecture
|
|
8
|
+
walkthrough, a handbook, editor hover-to-explain (LSP), and a chat that knows
|
|
9
|
+
your code. Runs on your own model key (Gemini free tier / local Ollama).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2024 OnePort Contributors
|
|
3
|
+
"""
|
|
4
|
+
Chat retrieval + answer.
|
|
5
|
+
|
|
6
|
+
Keeps it grounded: rank the indexed files against the question, read the top ones
|
|
7
|
+
from disk (nothing was uploaded — the code is right there), stuff them into the
|
|
8
|
+
prompt, and let the model answer citing real paths. No embeddings needed for a
|
|
9
|
+
first cut; keyword scoring over path + summary + symbols is fast and works.
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import re
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from oneport_context.models import RepoIndex
|
|
17
|
+
|
|
18
|
+
_FILE_CAP = 8000 # chars per file in the prompt
|
|
19
|
+
_CTX_BUDGET = 60_000 # total chars of code context
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def retrieve(index: RepoIndex, question: str, k: int = 15) -> tuple[str, list[str]]:
|
|
23
|
+
"""Return (code_context, cited_paths) for the files most relevant to `question`."""
|
|
24
|
+
tokens = set(re.findall(r"\w+", question.lower()))
|
|
25
|
+
root = Path(index.root)
|
|
26
|
+
|
|
27
|
+
scored = []
|
|
28
|
+
for f in index.all_files():
|
|
29
|
+
blob = f"{f.path} {f.summary} {' '.join(s.name for s in f.symbols)}".lower()
|
|
30
|
+
score = sum(3 if t in f.path.lower() else 1 for t in tokens if t in blob)
|
|
31
|
+
scored.append((score, f))
|
|
32
|
+
scored.sort(key=lambda x: -x[0])
|
|
33
|
+
|
|
34
|
+
picks = [f for s, f in scored[:k] if s > 0] or [f for _, f in scored[:5]]
|
|
35
|
+
parts, cited, used = [], [], 0
|
|
36
|
+
for f in picks:
|
|
37
|
+
content = _read(root / f.path)
|
|
38
|
+
if not content:
|
|
39
|
+
continue
|
|
40
|
+
block = f"\n### {f.path} [{f.language}]\n{content[:_FILE_CAP]}\n"
|
|
41
|
+
if used + len(block) > _CTX_BUDGET:
|
|
42
|
+
break
|
|
43
|
+
parts.append(block)
|
|
44
|
+
cited.append(f.path)
|
|
45
|
+
used += len(block)
|
|
46
|
+
return "".join(parts), cited
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
async def answer(index: RepoIndex, llm, history: list[tuple[str, str]], question: str) -> tuple[str, list[str]]:
|
|
50
|
+
"""Answer `question` about the repo, grounded in retrieved files. Returns (answer, cited)."""
|
|
51
|
+
from oneport_debug_core.llm.base import LLMCompletionOptions
|
|
52
|
+
context, cited = retrieve(index, question)
|
|
53
|
+
convo = "\n".join(f"Q: {q}\nA: {a}" for q, a in history[-4:])
|
|
54
|
+
prompt = (
|
|
55
|
+
f"You are an expert on the codebase '{index.name}'. Answer the question using the "
|
|
56
|
+
f"actual source files below. Be precise and technical, and cite specific file paths.\n\n"
|
|
57
|
+
f"=== Relevant files ===\n{context}\n\n"
|
|
58
|
+
+ (f"=== Conversation so far ===\n{convo}\n\n" if convo else "")
|
|
59
|
+
+ f"=== Question ===\n{question}\n\nAnswer:"
|
|
60
|
+
)
|
|
61
|
+
text = await llm.complete(prompt, LLMCompletionOptions(temperature=0.2, max_tokens=1500))
|
|
62
|
+
return text.strip(), cited
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _read(path: Path) -> str:
|
|
66
|
+
try:
|
|
67
|
+
return path.read_text(encoding="utf-8", errors="replace")
|
|
68
|
+
except OSError:
|
|
69
|
+
return ""
|