graphkeeper-cli 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.
- graphkeeper_cli-0.1.0/.gitignore +8 -0
- graphkeeper_cli-0.1.0/LICENSE +191 -0
- graphkeeper_cli-0.1.0/PKG-INFO +264 -0
- graphkeeper_cli-0.1.0/README.md +229 -0
- graphkeeper_cli-0.1.0/examples/README.md +29 -0
- graphkeeper_cli-0.1.0/pyproject.toml +65 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/__init__.py +71 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/build.py +48 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/cli.py +167 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/formatters.py +125 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/git.py +207 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/graphify.py +176 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/py.typed +0 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/query.py +114 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/store.py +121 -0
- graphkeeper_cli-0.1.0/src/graphkeeper/types.py +149 -0
- graphkeeper_cli-0.1.0/tests/__init__.py +0 -0
- graphkeeper_cli-0.1.0/tests/conftest.py +52 -0
- graphkeeper_cli-0.1.0/tests/test_build.py +66 -0
- graphkeeper_cli-0.1.0/tests/test_cli.py +117 -0
- graphkeeper_cli-0.1.0/tests/test_formatters.py +167 -0
- graphkeeper_cli-0.1.0/tests/test_git.py +144 -0
- graphkeeper_cli-0.1.0/tests/test_graphify.py +204 -0
- graphkeeper_cli-0.1.0/tests/test_query.py +123 -0
- graphkeeper_cli-0.1.0/tests/test_store.py +129 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Rudrendu Paul
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: graphkeeper-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first CLI that mines git history for file-level co-change patterns and builds a queryable knowledge graph for AI coding agents, with optional enrichment from graphify's symbol/call-graph output when it is installed.
|
|
5
|
+
Project-URL: Homepage, https://github.com/RudrenduPaul/GraphKeeper
|
|
6
|
+
Project-URL: Repository, https://github.com/RudrenduPaul/GraphKeeper
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/RudrenduPaul/GraphKeeper/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/RudrenduPaul/GraphKeeper/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Documentation, https://github.com/RudrenduPaul/GraphKeeper/blob/main/docs/getting-started.md
|
|
10
|
+
Project-URL: Author - Rudrendu Paul, https://github.com/RudrenduPaul
|
|
11
|
+
Project-URL: Author - Sourav Nandy, https://github.com/Sourav-nandy-ai
|
|
12
|
+
Author: Rudrendu Paul, Sourav Nandy
|
|
13
|
+
License-Expression: Apache-2.0
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Keywords: agent-native,ai-agent,cli,co-change,code-intelligence,developer-tools,git,graphify,knowledge-graph,local-first
|
|
16
|
+
Classifier: Development Status :: 3 - Alpha
|
|
17
|
+
Classifier: Environment :: Console
|
|
18
|
+
Classifier: Intended Audience :: Developers
|
|
19
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
28
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
29
|
+
Requires-Python: >=3.9
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: build<2,>=1.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest<9,>=7.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: twine<7,>=5.0; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# graphkeeper-cli (Python)
|
|
37
|
+
|
|
38
|
+
A local-only CLI and library that mines your `git log` for which files
|
|
39
|
+
actually change together, then hands an AI coding agent a queryable answer
|
|
40
|
+
instead of a grep across the whole history.
|
|
41
|
+
|
|
42
|
+
[](https://pypi.org/project/graphkeeper-cli/)
|
|
43
|
+
[](https://github.com/RudrenduPaul/GraphKeeper/blob/main/LICENSE)
|
|
44
|
+
[](https://pypi.org/project/graphkeeper-cli/)
|
|
45
|
+
[](https://www.npmjs.com/package/graphkeeper-cli)
|
|
46
|
+
|
|
47
|
+
## Why this exists
|
|
48
|
+
|
|
49
|
+
An AI coding agent working solo on a codebase it doesn't fully know yet
|
|
50
|
+
usually has no fast way to answer "what else changes when I touch this
|
|
51
|
+
file?" short of scrolling `git log -p` or grepping blindly. GraphKeeper
|
|
52
|
+
mines the commit history that's already sitting on disk and turns it into
|
|
53
|
+
one queryable, local answer -- no server, no account, no embeddings API,
|
|
54
|
+
nothing leaves the machine. This package is the Python distribution -- a
|
|
55
|
+
genuine, independent port of the npm package's TypeScript source, not a
|
|
56
|
+
wrapper around the Node binary. It has zero third-party runtime
|
|
57
|
+
dependencies: only the Python standard library (`subprocess`, `argparse`,
|
|
58
|
+
`json`) and the real `git` binary on `PATH`.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install graphkeeper-cli
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
or with [uv](https://docs.astral.sh/uv/):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv add graphkeeper-cli
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Requires Python 3.9+ and `git` on your `PATH`. The complementary JS/TS
|
|
73
|
+
distribution installs the same way on the npm side: `npm install -g
|
|
74
|
+
graphkeeper-cli` (or `npx graphkeeper-cli build` to run it once without
|
|
75
|
+
installing) -- see the
|
|
76
|
+
[project README](https://github.com/RudrenduPaul/GraphKeeper#readme) for
|
|
77
|
+
that package. Both are first-class and maintained together; neither is
|
|
78
|
+
deprecated in favor of the other. As of this writing the npm package's own
|
|
79
|
+
publish to the npm registry has not yet been attempted (a separate,
|
|
80
|
+
unstarted task), but its source and this Python port are both complete and
|
|
81
|
+
kept in parity.
|
|
82
|
+
|
|
83
|
+
## Quickstart
|
|
84
|
+
|
|
85
|
+
Clone the repo and index it (works against any git repo, including this
|
|
86
|
+
one):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/RudrenduPaul/GraphKeeper.git
|
|
90
|
+
cd GraphKeeper/python
|
|
91
|
+
pip install -e .
|
|
92
|
+
graphkeeper build ..
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
GraphKeeper build complete: /path/to/GraphKeeper
|
|
97
|
+
|
|
98
|
+
Co-change graph: 6 commit(s) analyzed, 80 file pair(s) found
|
|
99
|
+
graphify enrichment: skipped -- graphify was not found on PATH. Install it with
|
|
100
|
+
`uv tool install graphifyy` (or `pipx install graphifyy`) for symbol/call-graph
|
|
101
|
+
enrichment; GraphKeeper works fine without it, in co-change-only mode.
|
|
102
|
+
|
|
103
|
+
Wrote /path/to/GraphKeeper/.graphkeeper/graph.json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
(Real output from running this Python CLI against the GraphKeeper repo's
|
|
107
|
+
own checkout, this early in its history -- co-change counts grow as the
|
|
108
|
+
codebase accumulates more commits. Byte-for-byte the same command against
|
|
109
|
+
the npm CLI, against the same checkout, produces the same numbers -- both
|
|
110
|
+
distributions mine the same `git log`.)
|
|
111
|
+
|
|
112
|
+
Now query it:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
graphkeeper query co-change src/git.ts
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
Files that historically change alongside "src/git.ts":
|
|
120
|
+
|
|
121
|
+
1 src/store.ts
|
|
122
|
+
1 src/types.ts
|
|
123
|
+
1 test/git.test.ts
|
|
124
|
+
1 test/store.test.ts
|
|
125
|
+
1 test/test-helpers.ts
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
If [graphify](https://github.com/Graphify-Labs/graphify) is installed
|
|
129
|
+
(`uv tool install graphifyy`), `graphkeeper build` automatically shells out
|
|
130
|
+
to its local, no-API-key `graphify extract --code-only` and merges its
|
|
131
|
+
symbol/call-graph into the same store, unlocking call-graph queries.
|
|
132
|
+
Without graphify installed, `graphkeeper query calls <symbol>` explains
|
|
133
|
+
exactly why the answer isn't available instead of crashing or returning an
|
|
134
|
+
empty result:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Call-graph query for "mineCoChange" is not available.
|
|
138
|
+
|
|
139
|
+
graphify was not found on PATH. Install it with `uv tool install graphifyy`
|
|
140
|
+
(or `pipx install graphifyy`) for symbol/call-graph enrichment; GraphKeeper
|
|
141
|
+
works fine without it, in co-change-only mode.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Every command also supports `--json` for scripts and agents.
|
|
145
|
+
|
|
146
|
+
## Using the library instead of the CLI
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from graphkeeper import build, query_co_change, BuildOptions
|
|
150
|
+
|
|
151
|
+
result = build(".", BuildOptions(skip_graphify=True))
|
|
152
|
+
print(f"{result.store.commits_analyzed} commit(s) analyzed")
|
|
153
|
+
|
|
154
|
+
co_change = query_co_change(result.store, "src/git.ts", limit=5)
|
|
155
|
+
for row in co_change.results:
|
|
156
|
+
print(row.count, row.file)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`graphkeeper.cli` is a thin `argparse` wrapper over these same functions,
|
|
160
|
+
so anything scriptable from the command line is also usable directly from
|
|
161
|
+
Python -- the agent-native path.
|
|
162
|
+
|
|
163
|
+
## CLI reference
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
usage: graphkeeper [-h] [-V] {build,query} ...
|
|
167
|
+
|
|
168
|
+
Commands:
|
|
169
|
+
build [options] [path] Mine git history for co-change and (if available)
|
|
170
|
+
merge in graphify's symbol/call graph
|
|
171
|
+
query co-change <file> List files that historically change alongside
|
|
172
|
+
<file>, ranked by co-change frequency
|
|
173
|
+
query calls <symbol> Show callers/callees of <symbol> (requires
|
|
174
|
+
graphify enrichment)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `graphkeeper build [path]`
|
|
178
|
+
|
|
179
|
+
Walks `path` (default: current directory), runs `git log --no-merges
|
|
180
|
+
--name-only` across the whole history, and counts how often each pair of
|
|
181
|
+
files was touched in the same commit. Writes the result to
|
|
182
|
+
`.graphkeeper/graph.json`.
|
|
183
|
+
|
|
184
|
+
| Option | Description |
|
|
185
|
+
|---|---|
|
|
186
|
+
| `--json` | emit machine-readable JSON instead of human-readable text |
|
|
187
|
+
| `--max-files-per-commit <n>` | skip commits touching more than this many files (default: 100) -- keeps a single mass-reformat or vendoring commit from drowning out real co-change signal |
|
|
188
|
+
| `--no-graphify` | skip graphify enrichment even if graphify is installed |
|
|
189
|
+
|
|
190
|
+
### `graphkeeper query co-change <file>`
|
|
191
|
+
|
|
192
|
+
Lists files that historically changed alongside `<file>`, ranked by how
|
|
193
|
+
many commits touched both.
|
|
194
|
+
|
|
195
|
+
| Option | Description |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `--json` | emit machine-readable JSON instead of human-readable text |
|
|
198
|
+
| `--limit <n>` | cap the number of results |
|
|
199
|
+
| `--graph <path>` | path to a specific `graph.json` (default: `<cwd>/.graphkeeper/graph.json`) |
|
|
200
|
+
|
|
201
|
+
Exit code `0` when results are found, `1` when there's no co-change data
|
|
202
|
+
for that file yet, `2` on a usage or filesystem error.
|
|
203
|
+
|
|
204
|
+
### `graphkeeper query calls <symbol>`
|
|
205
|
+
|
|
206
|
+
Shows callers and callees of `<symbol>`, using graphify's `calls` edges
|
|
207
|
+
from the most recent `build`. Only meaningful when that build included
|
|
208
|
+
graphify enrichment -- if it didn't, this prints a clear explanation of why
|
|
209
|
+
(never a crash, never a silent empty result).
|
|
210
|
+
|
|
211
|
+
| Option | Description |
|
|
212
|
+
|---|---|
|
|
213
|
+
| `--json` | emit machine-readable JSON instead of human-readable text |
|
|
214
|
+
| `--graph <path>` | path to a specific `graph.json` (default: `<cwd>/.graphkeeper/graph.json`) |
|
|
215
|
+
|
|
216
|
+
Exit code `0` when the symbol is found, `1` when it isn't (or enrichment
|
|
217
|
+
wasn't available), `2` on a usage or filesystem error.
|
|
218
|
+
|
|
219
|
+
## How it works
|
|
220
|
+
|
|
221
|
+
Same pipeline as the npm package (see the
|
|
222
|
+
[project README](https://github.com/RudrenduPaul/GraphKeeper#how-it-works)
|
|
223
|
+
for the full narrative): `git log --no-merges --name-only` mined via a safe
|
|
224
|
+
argv-list subprocess call (never a shell string), pairs of co-changed files
|
|
225
|
+
counted per commit (commits touching more than `--max-files-per-commit`
|
|
226
|
+
files skipped), optionally merged with graphify's local symbol/call graph
|
|
227
|
+
when graphify is on `PATH`, and written once, atomically, to
|
|
228
|
+
`.graphkeeper/graph.json`. The on-disk JSON schema uses the same field
|
|
229
|
+
names (`commitsAnalyzed`, `coChange`, `fileCommitCounts`, etc.) as the npm
|
|
230
|
+
package's store, so a `.graphkeeper/graph.json` written by either
|
|
231
|
+
distribution can be read back by the other.
|
|
232
|
+
|
|
233
|
+
## Security
|
|
234
|
+
|
|
235
|
+
- Every `git` and `graphify` invocation uses an argv list passed directly
|
|
236
|
+
to the OS (`subprocess.run`, `shell=False`), never a shell string, so
|
|
237
|
+
commit messages, file names, or repo paths can't be interpreted as shell
|
|
238
|
+
syntax.
|
|
239
|
+
- `.graphkeeper/` output paths are checked against the resolved repo root
|
|
240
|
+
before every write (symlinks included), so a maliciously crafted repo
|
|
241
|
+
can't redirect GraphKeeper's writes outside `.graphkeeper/`.
|
|
242
|
+
- No telemetry, no network calls, no secrets, zero third-party runtime
|
|
243
|
+
dependencies. The only files GraphKeeper reads are `git log` output and
|
|
244
|
+
(optionally) graphify's own `graph.json`; the only file it writes is
|
|
245
|
+
`.graphkeeper/graph.json`.
|
|
246
|
+
- See [SECURITY.md](https://github.com/RudrenduPaul/GraphKeeper/blob/main/SECURITY.md)
|
|
247
|
+
for the private disclosure process.
|
|
248
|
+
|
|
249
|
+
## Contributing
|
|
250
|
+
|
|
251
|
+
See [CONTRIBUTING.md](https://github.com/RudrenduPaul/GraphKeeper/blob/main/CONTRIBUTING.md)
|
|
252
|
+
for the full guide, covering both the TypeScript and Python codebases (they
|
|
253
|
+
must stay in behavioral parity). To build from source:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
cd python
|
|
257
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
258
|
+
pip install -e ".[dev]"
|
|
259
|
+
pytest
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
Apache 2.0, see [LICENSE](https://github.com/RudrenduPaul/GraphKeeper/blob/main/LICENSE).
|