ontosight-codegraph 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.
@@ -0,0 +1,173 @@
1
+ temp/
2
+ logs/
3
+ .trae/
4
+ .github/agents/
5
+ .claude/
6
+
7
+ # Byte-compiled / optimized / DLL files
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+
12
+ # C extensions
13
+ *.so
14
+
15
+ # Distribution / packaging
16
+ .Python
17
+ build/
18
+ develop-eggs/
19
+ dist/
20
+ downloads/
21
+ eggs/
22
+ .eggs/
23
+ lib/
24
+ lib64/
25
+ parts/
26
+ sdist/
27
+ var/
28
+ wheels/
29
+ share/python-wheels/
30
+ *.egg-info/
31
+ .installed.cfg
32
+ *.egg
33
+ MANIFEST
34
+
35
+ # PyInstaller
36
+ # Usually these files are written by a python script from a template
37
+ # before PyInstaller builds the exe, so may be deleted later.
38
+ *.manifest
39
+ *.spec
40
+
41
+ # Installer logs
42
+ pip-log.txt
43
+ pip-delete-this-directory.txt
44
+
45
+ # Unit test / coverage reports
46
+ htmlcov/
47
+ .tox/
48
+ .nosuch/
49
+ .nosuch/
50
+ .pytest_cache/
51
+ v/
52
+ .v/
53
+ nosetests.xml
54
+ coverage.xml
55
+ *.cover
56
+ *.py,cover
57
+ .tracker
58
+ .hypothesis/
59
+ .pytest_cache/
60
+ cover/
61
+
62
+ # Translations
63
+ *.mo
64
+ *.pot
65
+
66
+ # Django stuff:
67
+ *.log
68
+ local_settings.py
69
+ db.sqlite3
70
+ db.sqlite3-journal
71
+
72
+ # Flask stuff:
73
+ instance/
74
+ .webassets-cache
75
+
76
+ # Scrapy stuff:
77
+ .scrapy
78
+
79
+ # Sphinx documentation
80
+ docs/_build/
81
+
82
+ # PyBuilder
83
+ .pybuilder/
84
+ target/
85
+
86
+ # Jupyter Notebook
87
+ .ipynb_checkpoints
88
+
89
+ # IPython
90
+ profile_default/
91
+ ipython_config.py
92
+
93
+ # pyenv
94
+ # For a library or package, you might want to ignore these files since the Python version is
95
+ # usually managed by the user. However, for a specific project, it might be useful to check them in.
96
+ # .python-version
97
+
98
+ # pipenv
99
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
100
+ # However, in case of collaboration, if you want to keep your dependencies next to your project code:
101
+ # Pipfile.lock
102
+
103
+ # poetry
104
+ # Similar to Pipenv, poetry.lock is generally recommended to be committed.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ # poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipenv, pdm.lock is generally recommended to be committed.
110
+ # .pdm-python
111
+ # .pdm-build/
112
+
113
+ # PEP 582; used by e.g. github.com/fannheyward/coc-pyright
114
+ __pypackages__/
115
+
116
+ # Celery stuff
117
+ celerybeat-schedule
118
+ celerybeat.pid
119
+
120
+ # SageMath parsed files
121
+ *.sage.py
122
+
123
+ # Environments
124
+ .env
125
+ .venv
126
+ env/
127
+ venv/
128
+ ENV/
129
+ env.bak/
130
+ venv.bak/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ .idea/
158
+
159
+ # VS Code
160
+ .vscode/
161
+ .history/
162
+
163
+ # OS
164
+ .DS_Store
165
+ Thumbs.db
166
+ .bg-shell/
167
+ .gsd/
168
+ kb/
169
+ .graphify-out/
170
+
171
+ # Claude superpowers plans (keep repo docs clean)
172
+ docs/superpowers/
173
+ .codegraph/
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: ontosight-codegraph
3
+ Version: 0.1.0
4
+ Summary: Visualize CodeGraph call subgraphs in OntoSight
5
+ Project-URL: Homepage, https://github.com/yifanfeng97/hyper-extract
6
+ Project-URL: Repository, https://github.com/yifanfeng97/hyper-extract
7
+ Author-email: Yifan Feng <evanfeng97@gmail.com>
8
+ License: Apache-2.0
9
+ Keywords: call-graph,codegraph,ontosight,visualization
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: networkx>=3.0
18
+ Requires-Dist: ontosight>=0.2.0
19
+ Requires-Dist: pydantic>=2.0
20
+ Requires-Dist: rich>=13.7.0
21
+ Requires-Dist: typer>=0.13.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=9.0.0; extra == 'dev'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # OntoSight CodeGraph
27
+
28
+ Read a local [CodeGraph](https://github.com/colbymchenry/codegraph) index (`.codegraph/codegraph.db`) and visualize call subgraphs in [OntoSight](https://pypi.org/project/ontosight/).
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install ontosight-codegraph
34
+ # or
35
+ uvx ontosight-codegraph .
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```bash
41
+ # Ensure index exists
42
+ npx @colbymchenry/codegraph init -i
43
+
44
+ # Auto-seed from highest fan-in symbols
45
+ ontosight-codegraph .
46
+
47
+ # Seed around a symbol
48
+ ontosight-codegraph . --symbol view_graph --path vendor/ontosight/
49
+
50
+ # Task-scoped subgraph
51
+ ontosight-codegraph . --task "auth flow" --hops 2 --max-nodes 200
52
+ ```
53
+
54
+ ## npm wrapper
55
+
56
+ For a zero-Python-install workflow (uses `uvx` under the hood; auto-runs CodeGraph init when the index is missing):
57
+
58
+ ```bash
59
+ npx @royalsolution/ontosight .
60
+ ```
61
+
62
+ See [`packages/ontosight/`](../ontosight/) and [`packages/ontosight/AGENTS.md`](../ontosight/AGENTS.md) for npm package details and **AI agent usage**.
63
+
64
+ ## Publish (maintainers)
65
+
66
+ ```bash
67
+ cd packages/ontosight-codegraph
68
+ python -m build
69
+ twine check dist/*
70
+ twine upload dist/*
71
+ ```
@@ -0,0 +1,22 @@
1
+ # Publishing ontosight-codegraph to PyPI
2
+
3
+ Maintainers only.
4
+
5
+ ## Prerequisites
6
+
7
+ Publish **ontosight** 0.2.x first (see [`vendor/ontosight/PUBLISH.md`](../../vendor/ontosight/PUBLISH.md)).
8
+
9
+ ```bash
10
+ pip install build twine
11
+ ```
12
+
13
+ ## Build and publish
14
+
15
+ ```bash
16
+ cd packages/ontosight-codegraph
17
+ python -m build
18
+ twine check dist/*
19
+ twine upload dist/*
20
+ ```
21
+
22
+ After publishing, bump `ontosightCodegraphVersion` in `packages/ontosight/package.json` and publish the npm wrapper.
@@ -0,0 +1,46 @@
1
+ # OntoSight CodeGraph
2
+
3
+ Read a local [CodeGraph](https://github.com/colbymchenry/codegraph) index (`.codegraph/codegraph.db`) and visualize call subgraphs in [OntoSight](https://pypi.org/project/ontosight/).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install ontosight-codegraph
9
+ # or
10
+ uvx ontosight-codegraph .
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Ensure index exists
17
+ npx @colbymchenry/codegraph init -i
18
+
19
+ # Auto-seed from highest fan-in symbols
20
+ ontosight-codegraph .
21
+
22
+ # Seed around a symbol
23
+ ontosight-codegraph . --symbol view_graph --path vendor/ontosight/
24
+
25
+ # Task-scoped subgraph
26
+ ontosight-codegraph . --task "auth flow" --hops 2 --max-nodes 200
27
+ ```
28
+
29
+ ## npm wrapper
30
+
31
+ For a zero-Python-install workflow (uses `uvx` under the hood; auto-runs CodeGraph init when the index is missing):
32
+
33
+ ```bash
34
+ npx @royalsolution/ontosight .
35
+ ```
36
+
37
+ See [`packages/ontosight/`](../ontosight/) and [`packages/ontosight/AGENTS.md`](../ontosight/AGENTS.md) for npm package details and **AI agent usage**.
38
+
39
+ ## Publish (maintainers)
40
+
41
+ ```bash
42
+ cd packages/ontosight-codegraph
43
+ python -m build
44
+ twine check dist/*
45
+ twine upload dist/*
46
+ ```
@@ -0,0 +1,38 @@
1
+ """CodeGraph → OntoSight integration for standalone and Hyper-Extract use."""
2
+
3
+ from ontosight_codegraph.query import make_query_callback
4
+ from ontosight_codegraph.store import (
5
+ INIT_HINT,
6
+ CALL_EDGE_KIND,
7
+ EXCLUDED_NODE_KINDS,
8
+ CodeCallEdge,
9
+ CodeGraphNotFoundError,
10
+ CodeGraphStore,
11
+ CodeSymbolNode,
12
+ SubgraphResult,
13
+ load_call_subgraph,
14
+ make_search_callback,
15
+ merge_query_params,
16
+ parse_codegraph_query,
17
+ resolve_codegraph_db,
18
+ )
19
+ from ontosight_codegraph.view import apply_subgraph_to_view, show_codegraph
20
+
21
+ __all__ = [
22
+ "INIT_HINT",
23
+ "CALL_EDGE_KIND",
24
+ "EXCLUDED_NODE_KINDS",
25
+ "CodeCallEdge",
26
+ "CodeGraphNotFoundError",
27
+ "CodeGraphStore",
28
+ "CodeSymbolNode",
29
+ "SubgraphResult",
30
+ "apply_subgraph_to_view",
31
+ "load_call_subgraph",
32
+ "make_query_callback",
33
+ "make_search_callback",
34
+ "merge_query_params",
35
+ "parse_codegraph_query",
36
+ "resolve_codegraph_db",
37
+ "show_codegraph",
38
+ ]
@@ -0,0 +1,96 @@
1
+ """CLI for visualizing CodeGraph call subgraphs in OntoSight."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ import typer
9
+
10
+ from ontosight_codegraph.store import CodeGraphNotFoundError
11
+ from ontosight_codegraph.view import show_codegraph
12
+
13
+ app = typer.Typer(
14
+ help="Visualize CodeGraph call subgraphs with OntoSight.",
15
+ add_completion=False,
16
+ no_args_is_help=True,
17
+ )
18
+
19
+
20
+ @app.command()
21
+ def show(
22
+ project_path: str = typer.Argument(
23
+ ".",
24
+ help="Project root containing .codegraph/codegraph.db",
25
+ ),
26
+ path_filter: Optional[str] = typer.Option(
27
+ None,
28
+ "--path",
29
+ help="Limit symbols to files under this path prefix",
30
+ ),
31
+ symbol: Optional[str] = typer.Option(
32
+ None,
33
+ "--symbol",
34
+ help="Seed symbol name for subgraph expansion",
35
+ ),
36
+ task: Optional[str] = typer.Option(
37
+ None,
38
+ "--task",
39
+ help="Natural-language task to seed subgraph (keyword match)",
40
+ ),
41
+ hops: int = typer.Option(
42
+ 2,
43
+ "--hops",
44
+ min=0,
45
+ help="BFS hop depth for subgraph expansion",
46
+ ),
47
+ max_nodes: int = typer.Option(
48
+ 200,
49
+ "--max-nodes",
50
+ min=1,
51
+ help="Maximum nodes in subgraph",
52
+ ),
53
+ ) -> None:
54
+ """Open OntoSight with a CodeGraph call subgraph."""
55
+ root = Path(project_path).resolve()
56
+ typer.echo(f"Project: {root}")
57
+ if path_filter:
58
+ typer.echo(f"Path filter: {path_filter}")
59
+ if symbol:
60
+ typer.echo(f"Symbol seed: {symbol}")
61
+ elif task:
62
+ typer.echo(f"Task seed: {task}")
63
+ typer.echo(f"Hops / max nodes: {hops} / {max_nodes}")
64
+ typer.echo()
65
+
66
+ try:
67
+ typer.echo("Visualizing CodeGraph with OntoSight...")
68
+ result = show_codegraph(
69
+ root,
70
+ path_filter=path_filter,
71
+ symbol=symbol,
72
+ task=task,
73
+ hops=hops,
74
+ max_nodes=max_nodes,
75
+ print_topology_summary=True,
76
+ )
77
+ except CodeGraphNotFoundError as exc:
78
+ typer.echo(f"Error: {exc}", err=True)
79
+ raise typer.Exit(1) from exc
80
+ except ValueError as exc:
81
+ typer.echo(f"Error: {exc}", err=True)
82
+ raise typer.Exit(1) from exc
83
+
84
+ typer.echo(
85
+ f"Loaded {len(result.nodes)} nodes, {len(result.edges)} call edges"
86
+ )
87
+ if result.truncated:
88
+ typer.echo(
89
+ f"Warning: Subgraph truncated at {max_nodes} nodes. "
90
+ "Use --symbol, --task, or --path to narrow scope.",
91
+ err=True,
92
+ )
93
+
94
+
95
+ if __name__ == "__main__":
96
+ app()
@@ -0,0 +1,59 @@
1
+ """CodeGraph query callback for OntoSight live subgraph reload."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any, Callable, Dict, Optional
7
+
8
+ from ontosight_codegraph.store import (
9
+ load_call_subgraph,
10
+ merge_query_params,
11
+ )
12
+ from ontosight_codegraph.view import apply_subgraph_to_view
13
+
14
+
15
+ def make_query_callback(
16
+ project_path: Path,
17
+ *,
18
+ default_path_filter: Optional[str] = None,
19
+ default_hops: int = 2,
20
+ default_max_nodes: int = 200,
21
+ top_k_critical: int = 10,
22
+ highlight_critical: bool = True,
23
+ ) -> Callable[..., Dict[str, Any]]:
24
+ """Create OntoSight callback to reload CodeGraph subgraph from query input."""
25
+
26
+ def codegraph_query(
27
+ query: Optional[str] = None,
28
+ path_filter: Optional[str] = None,
29
+ symbol: Optional[str] = None,
30
+ task: Optional[str] = None,
31
+ hops: Optional[int] = None,
32
+ max_nodes: Optional[int] = None,
33
+ **_: Any,
34
+ ) -> Dict[str, Any]:
35
+ params = merge_query_params(
36
+ query=query,
37
+ path_filter=path_filter,
38
+ symbol=symbol,
39
+ task=task,
40
+ hops=hops if hops is not None else default_hops,
41
+ max_nodes=max_nodes if max_nodes is not None else default_max_nodes,
42
+ default_path_filter=default_path_filter,
43
+ )
44
+ load_kwargs = {
45
+ "path_filter": params.get("path_filter"),
46
+ "symbol": params.get("symbol"),
47
+ "task": params.get("task"),
48
+ "hops": params.get("hops", default_hops),
49
+ "max_nodes": params.get("max_nodes", default_max_nodes),
50
+ }
51
+ result = load_call_subgraph(project_path, **load_kwargs)
52
+ return apply_subgraph_to_view(
53
+ result,
54
+ max_nodes=load_kwargs["max_nodes"],
55
+ top_k_critical=top_k_critical,
56
+ highlight_critical=highlight_critical,
57
+ )
58
+
59
+ return codegraph_query