@duytransipher/gitnexus 1.4.6-sipher.0
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.
- package/LICENSE +73 -0
- package/README.md +261 -0
- package/dist/cli/ai-context.d.ts +23 -0
- package/dist/cli/ai-context.js +265 -0
- package/dist/cli/analyze.d.ts +12 -0
- package/dist/cli/analyze.js +345 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +37 -0
- package/dist/cli/eval-server.js +389 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +30 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +36 -0
- package/dist/cli/serve.d.ts +4 -0
- package/dist/cli/serve.js +6 -0
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +367 -0
- package/dist/cli/sipher-patched.d.ts +2 -0
- package/dist/cli/sipher-patched.js +77 -0
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +36 -0
- package/dist/cli/tool.d.ts +60 -0
- package/dist/cli/tool.js +180 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +365 -0
- package/dist/config/ignore-service.d.ts +26 -0
- package/dist/config/ignore-service.js +284 -0
- package/dist/config/supported-languages.d.ts +15 -0
- package/dist/config/supported-languages.js +16 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +240 -0
- package/dist/core/embeddings/embedder.d.ts +60 -0
- package/dist/core/embeddings/embedder.js +251 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
- package/dist/core/embeddings/embedding-pipeline.js +356 -0
- package/dist/core/embeddings/index.d.ts +9 -0
- package/dist/core/embeddings/index.js +9 -0
- package/dist/core/embeddings/text-generator.d.ts +24 -0
- package/dist/core/embeddings/text-generator.js +182 -0
- package/dist/core/embeddings/types.d.ts +87 -0
- package/dist/core/embeddings/types.js +32 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +66 -0
- package/dist/core/graph/types.d.ts +66 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/ingestion/ast-cache.d.ts +11 -0
- package/dist/core/ingestion/ast-cache.js +35 -0
- package/dist/core/ingestion/call-processor.d.ts +23 -0
- package/dist/core/ingestion/call-processor.js +793 -0
- package/dist/core/ingestion/call-routing.d.ts +68 -0
- package/dist/core/ingestion/call-routing.js +129 -0
- package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
- package/dist/core/ingestion/cluster-enricher.js +170 -0
- package/dist/core/ingestion/community-processor.d.ts +39 -0
- package/dist/core/ingestion/community-processor.js +312 -0
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
- package/dist/core/ingestion/entry-point-scoring.js +353 -0
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +81 -0
- package/dist/core/ingestion/framework-detection.d.ts +54 -0
- package/dist/core/ingestion/framework-detection.js +411 -0
- package/dist/core/ingestion/heritage-processor.d.ts +28 -0
- package/dist/core/ingestion/heritage-processor.js +251 -0
- package/dist/core/ingestion/import-processor.d.ts +34 -0
- package/dist/core/ingestion/import-processor.js +398 -0
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +19 -0
- package/dist/core/ingestion/parsing-processor.js +315 -0
- package/dist/core/ingestion/pipeline.d.ts +6 -0
- package/dist/core/ingestion/pipeline.js +401 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +315 -0
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/structure-processor.d.ts +2 -0
- package/dist/core/ingestion/structure-processor.js +36 -0
- package/dist/core/ingestion/symbol-table.d.ts +63 -0
- package/dist/core/ingestion/symbol-table.js +85 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
- package/dist/core/ingestion/tree-sitter-queries.js +888 -0
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +613 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +455 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +456 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
- package/dist/core/ingestion/type-extractors/shared.js +810 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/types.js +1 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +138 -0
- package/dist/core/ingestion/utils.js +1290 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
- package/dist/core/ingestion/workers/parse-worker.js +1126 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +128 -0
- package/dist/core/lbug/csv-generator.d.ts +33 -0
- package/dist/core/lbug/csv-generator.js +366 -0
- package/dist/core/lbug/lbug-adapter.d.ts +103 -0
- package/dist/core/lbug/lbug-adapter.js +769 -0
- package/dist/core/lbug/schema.d.ts +53 -0
- package/dist/core/lbug/schema.js +430 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +96 -0
- package/dist/core/search/hybrid-search.d.ts +49 -0
- package/dist/core/search/hybrid-search.js +118 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
- package/dist/core/tree-sitter/parser-loader.js +63 -0
- package/dist/core/wiki/generator.d.ts +120 -0
- package/dist/core/wiki/generator.js +939 -0
- package/dist/core/wiki/graph-queries.d.ts +80 -0
- package/dist/core/wiki/graph-queries.js +238 -0
- package/dist/core/wiki/html-viewer.d.ts +10 -0
- package/dist/core/wiki/html-viewer.js +297 -0
- package/dist/core/wiki/llm-client.d.ts +43 -0
- package/dist/core/wiki/llm-client.js +186 -0
- package/dist/core/wiki/prompts.d.ts +53 -0
- package/dist/core/wiki/prompts.js +174 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/lbug-adapter.d.ts +57 -0
- package/dist/mcp/core/lbug-adapter.js +455 -0
- package/dist/mcp/local/local-backend.d.ts +181 -0
- package/dist/mcp/local/local-backend.js +1722 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +411 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +296 -0
- package/dist/mcp/staleness.d.ts +15 -0
- package/dist/mcp/staleness.js +29 -0
- package/dist/mcp/tools.d.ts +24 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/server/api.d.ts +10 -0
- package/dist/server/api.js +344 -0
- package/dist/server/mcp-http.d.ts +13 -0
- package/dist/server/mcp-http.js +100 -0
- package/dist/storage/git.d.ts +6 -0
- package/dist/storage/git.js +35 -0
- package/dist/storage/repo-manager.d.ts +138 -0
- package/dist/storage/repo-manager.js +299 -0
- package/dist/types/pipeline.d.ts +32 -0
- package/dist/types/pipeline.js +18 -0
- package/dist/unreal/bridge.d.ts +4 -0
- package/dist/unreal/bridge.js +113 -0
- package/dist/unreal/config.d.ts +6 -0
- package/dist/unreal/config.js +55 -0
- package/dist/unreal/types.d.ts +105 -0
- package/dist/unreal/types.js +1 -0
- package/hooks/claude/gitnexus-hook.cjs +238 -0
- package/hooks/claude/pre-tool-use.sh +79 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +100 -0
- package/scripts/ensure-cli-executable.cjs +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +74 -0
- package/scripts/setup-unreal-gitnexus.ps1 +191 -0
- package/skills/gitnexus-cli.md +82 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +121 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
12
|
+
|
|
13
|
+
## Distribution License
|
|
14
|
+
|
|
15
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
16
|
+
|
|
17
|
+
## Notices
|
|
18
|
+
|
|
19
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
20
|
+
|
|
21
|
+
> Required Notice: Copyright Abhigyan Patwari (https://github.com/abhigyanpatwari/GitNexus)
|
|
22
|
+
|
|
23
|
+
## Changes and New Works License
|
|
24
|
+
|
|
25
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Patent License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
30
|
+
|
|
31
|
+
## Noncommercial Purposes
|
|
32
|
+
|
|
33
|
+
Any noncommercial purpose is a permitted purpose.
|
|
34
|
+
|
|
35
|
+
## Personal Uses
|
|
36
|
+
|
|
37
|
+
Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
|
|
38
|
+
|
|
39
|
+
## Noncommercial Organizations
|
|
40
|
+
|
|
41
|
+
Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
|
|
42
|
+
|
|
43
|
+
## Fair Use
|
|
44
|
+
|
|
45
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
46
|
+
|
|
47
|
+
## No Other Rights
|
|
48
|
+
|
|
49
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
50
|
+
|
|
51
|
+
## Patent Defense
|
|
52
|
+
|
|
53
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
54
|
+
|
|
55
|
+
## Violations
|
|
56
|
+
|
|
57
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
58
|
+
|
|
59
|
+
## No Liability
|
|
60
|
+
|
|
61
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
62
|
+
|
|
63
|
+
## Definitions
|
|
64
|
+
|
|
65
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
66
|
+
|
|
67
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
68
|
+
|
|
69
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
70
|
+
|
|
71
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
72
|
+
|
|
73
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# GitNexus
|
|
2
|
+
|
|
3
|
+
A Sipher-maintained npm distribution of GitNexus.
|
|
4
|
+
|
|
5
|
+
**Graph-powered code intelligence for AI agents.** Index any codebase into a knowledge graph, then query it via MCP or CLI.
|
|
6
|
+
|
|
7
|
+
Works with **Cursor**, **Claude Code**, **Windsurf**, **Cline**, **OpenCode**, and any MCP-compatible tool.
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@duytransipher/gitnexus)
|
|
10
|
+
[](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Why?
|
|
15
|
+
|
|
16
|
+
AI coding tools don't understand your codebase structure. They edit a function without knowing 47 other functions depend on it. GitNexus fixes this by **precomputing every dependency, call chain, and relationship** into a queryable graph.
|
|
17
|
+
|
|
18
|
+
**Three commands to give your AI agent full codebase awareness.**
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Run once without installing globally
|
|
24
|
+
npx @duytransipher/gitnexus@latest analyze
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's it. This indexes the codebase, installs agent skills, registers Claude Code hooks, and creates `AGENTS.md` / `CLAUDE.md` context files — all in one command.
|
|
28
|
+
|
|
29
|
+
Install globally if you want the persistent `gitnexus` CLI:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g @duytransipher/gitnexus
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To configure MCP for your editor, run `npx @duytransipher/gitnexus@latest setup` once — or set it up manually below. After a global install, the executable name stays `gitnexus`.
|
|
36
|
+
|
|
37
|
+
`gitnexus setup` auto-detects your editors and writes the correct global MCP config. You only need to run it once.
|
|
38
|
+
|
|
39
|
+
### Editor Support
|
|
40
|
+
|
|
41
|
+
| Editor | MCP | Skills | Hooks (auto-augment) | Support |
|
|
42
|
+
|--------|-----|--------|---------------------|---------|
|
|
43
|
+
| **Claude Code** | Yes | Yes | Yes (PreToolUse) | **Full** |
|
|
44
|
+
| **Cursor** | Yes | Yes | — | MCP + Skills |
|
|
45
|
+
| **Windsurf** | Yes | — | — | MCP |
|
|
46
|
+
| **OpenCode** | Yes | Yes | — | MCP + Skills |
|
|
47
|
+
|
|
48
|
+
> **Claude Code** gets the deepest integration: MCP tools + agent skills + PreToolUse hooks that automatically enrich grep/glob/bash calls with knowledge graph context.
|
|
49
|
+
|
|
50
|
+
### Community Integrations
|
|
51
|
+
|
|
52
|
+
| Agent | Install | Source |
|
|
53
|
+
|-------|---------|--------|
|
|
54
|
+
| [pi](https://pi.dev) | `pi install npm:pi-gitnexus` | [pi-gitnexus](https://github.com/tintinweb/pi-gitnexus) |
|
|
55
|
+
|
|
56
|
+
## MCP Setup (manual)
|
|
57
|
+
|
|
58
|
+
If you prefer to configure manually instead of using `gitnexus setup`:
|
|
59
|
+
|
|
60
|
+
### Claude Code (full support — MCP + skills + hooks)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
claude mcp add gitnexus -- npx -y @duytransipher/gitnexus@latest mcp
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Cursor / Windsurf
|
|
67
|
+
|
|
68
|
+
Add to `~/.cursor/mcp.json` (global — works for all projects):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"gitnexus": {
|
|
74
|
+
"command": "npx",
|
|
75
|
+
"args": ["-y", "@duytransipher/gitnexus@latest", "mcp"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### OpenCode
|
|
82
|
+
|
|
83
|
+
Add to `~/.config/opencode/config.json`:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcp": {
|
|
88
|
+
"gitnexus": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "@duytransipher/gitnexus@latest", "mcp"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## How It Works
|
|
97
|
+
|
|
98
|
+
GitNexus builds a complete knowledge graph of your codebase through a multi-phase indexing pipeline:
|
|
99
|
+
|
|
100
|
+
1. **Structure** — Walks the file tree and maps folder/file relationships
|
|
101
|
+
2. **Parsing** — Extracts functions, classes, methods, and interfaces using Tree-sitter ASTs
|
|
102
|
+
3. **Resolution** — Resolves imports and function calls across files with language-aware logic
|
|
103
|
+
4. **Clustering** — Groups related symbols into functional communities
|
|
104
|
+
5. **Processes** — Traces execution flows from entry points through call chains
|
|
105
|
+
6. **Search** — Builds hybrid search indexes for fast retrieval
|
|
106
|
+
|
|
107
|
+
The result is a **LadybugDB graph database** stored locally in `.gitnexus/` with full-text search and semantic embeddings.
|
|
108
|
+
|
|
109
|
+
## MCP Tools
|
|
110
|
+
|
|
111
|
+
Your AI agent gets these tools automatically:
|
|
112
|
+
|
|
113
|
+
| Tool | What It Does | `repo` Param |
|
|
114
|
+
|------|-------------|--------------|
|
|
115
|
+
| `list_repos` | Discover all indexed repositories | — |
|
|
116
|
+
| `query` | Process-grouped hybrid search (BM25 + semantic + RRF) | Optional |
|
|
117
|
+
| `context` | 360-degree symbol view — categorized refs, process participation | Optional |
|
|
118
|
+
| `impact` | Blast radius analysis with depth grouping and confidence | Optional |
|
|
119
|
+
| `detect_changes` | Git-diff impact — maps changed lines to affected processes | Optional |
|
|
120
|
+
| `rename` | Multi-file coordinated rename with graph + text search | Optional |
|
|
121
|
+
| `cypher` | Raw Cypher graph queries | Optional |
|
|
122
|
+
| `sync_unreal_asset_manifest` | Refresh Unreal Blueprint manifest via the configured Unreal commandlet | Optional |
|
|
123
|
+
| `find_native_blueprint_references` | Confirm direct Blueprint references to a native C++ function | Optional |
|
|
124
|
+
| `expand_blueprint_chain` | Expand upstream/downstream Blueprint graph flow from a confirmed anchor | Optional |
|
|
125
|
+
| `find_blueprints_derived_from_native_class` | List Blueprint assets derived from a native class via the manifest | Optional |
|
|
126
|
+
|
|
127
|
+
> With one indexed repo, the `repo` param is optional. With multiple, specify which: `query({query: "auth", repo: "my-app"})`.
|
|
128
|
+
|
|
129
|
+
## MCP Resources
|
|
130
|
+
|
|
131
|
+
| Resource | Purpose |
|
|
132
|
+
|----------|---------|
|
|
133
|
+
| `gitnexus://repos` | List all indexed repositories (read first) |
|
|
134
|
+
| `gitnexus://repo/{name}/context` | Codebase stats, staleness check, and available tools |
|
|
135
|
+
| `gitnexus://repo/{name}/clusters` | All functional clusters with cohesion scores |
|
|
136
|
+
| `gitnexus://repo/{name}/cluster/{name}` | Cluster members and details |
|
|
137
|
+
| `gitnexus://repo/{name}/processes` | All execution flows |
|
|
138
|
+
| `gitnexus://repo/{name}/process/{name}` | Full process trace with steps |
|
|
139
|
+
| `gitnexus://repo/{name}/schema` | Graph schema for Cypher queries |
|
|
140
|
+
|
|
141
|
+
## MCP Prompts
|
|
142
|
+
|
|
143
|
+
| Prompt | What It Does |
|
|
144
|
+
|--------|-------------|
|
|
145
|
+
| `detect_impact` | Pre-commit change analysis — scope, affected processes, risk level |
|
|
146
|
+
| `generate_map` | Architecture documentation from the knowledge graph with mermaid diagrams |
|
|
147
|
+
|
|
148
|
+
## CLI Commands
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
gitnexus setup # Configure MCP for your editors (one-time)
|
|
152
|
+
gitnexus analyze [path] # Index a repository (or update stale index)
|
|
153
|
+
gitnexus analyze --force # Force full re-index
|
|
154
|
+
gitnexus analyze --embeddings # Enable embedding generation (slower, better search)
|
|
155
|
+
gitnexus analyze --verbose # Log skipped files when parsers are unavailable
|
|
156
|
+
gitnexus mcp # Start MCP server (stdio) — serves all indexed repos
|
|
157
|
+
gitnexus serve # Start local HTTP server (multi-repo) for web UI
|
|
158
|
+
gitnexus list # List all indexed repositories
|
|
159
|
+
gitnexus status # Show index status for current repo
|
|
160
|
+
gitnexus clean # Delete index for current repo
|
|
161
|
+
gitnexus clean --all --force # Delete all indexes
|
|
162
|
+
gitnexus wiki [path] # Generate LLM-powered docs from knowledge graph
|
|
163
|
+
gitnexus wiki --model <model> # Wiki with custom LLM model (default: gpt-4o-mini)
|
|
164
|
+
gitnexus sipher-patched [path] # Validate S2 repo shape and Sipher gateway env
|
|
165
|
+
gitnexus unreal-sync # Refresh Unreal Blueprint asset manifest for the current indexed repo
|
|
166
|
+
gitnexus unreal-find-refs <fn> # Confirm Blueprint references to a native C++ function
|
|
167
|
+
gitnexus unreal-expand-chain ... # Expand a Blueprint graph chain from a confirmed anchor
|
|
168
|
+
gitnexus unreal-derived-blueprints <class> # List Blueprints derived from a native class
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Unreal Blueprint References
|
|
172
|
+
|
|
173
|
+
GitNexus can bridge into an Unreal Editor commandlet to answer "which Blueprints call this native C++ function?" with graph-confirmed results.
|
|
174
|
+
|
|
175
|
+
1. Install the plugin from `../gitnexus-unreal/` into your Unreal project's `Plugins/` folder.
|
|
176
|
+
2. Create `.gitnexus/unreal/config.json` in the indexed repo:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"editor_cmd": "C:/Program Files/Epic Games/UE_5.5/Engine/Binaries/Win64/UnrealEditor-Cmd.exe",
|
|
181
|
+
"project_path": "D:/Projects/sipher_test_project/sipher_test_project.uproject",
|
|
182
|
+
"commandlet": "GitNexusBlueprintAnalyzer",
|
|
183
|
+
"timeout_ms": 300000
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
From this source repo, you can do both with:
|
|
188
|
+
|
|
189
|
+
```powershell
|
|
190
|
+
pwsh -File .\gitnexus\scripts\setup-unreal-gitnexus.ps1 -ProjectRoot D:\Projects\git_nexus_ue_lyra
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The script fails if the plugin or config already exists unless you pass `-Force`.
|
|
194
|
+
|
|
195
|
+
3. Refresh the manifest with `gitnexus unreal-sync`.
|
|
196
|
+
4. Query references with `gitnexus unreal-find-refs "AMyActor::MyBlueprintCallableFunction"`.
|
|
197
|
+
|
|
198
|
+
The manifest lives at `.gitnexus/unreal/asset-manifest.json`. GitNexus uses it only as a candidate shortlist; confirmed graph references still come from the Unreal commandlet.
|
|
199
|
+
|
|
200
|
+
## Multi-Repo Support
|
|
201
|
+
|
|
202
|
+
GitNexus supports indexing multiple repositories. Each `gitnexus analyze` registers the repo in a global registry (`~/.gitnexus/registry.json`). The MCP server serves all indexed repos automatically.
|
|
203
|
+
|
|
204
|
+
## Supported Languages
|
|
205
|
+
|
|
206
|
+
TypeScript, JavaScript, Python, Java, C, C++, C#, Go, Rust, PHP, Kotlin, Swift, Ruby
|
|
207
|
+
|
|
208
|
+
### Language Feature Matrix
|
|
209
|
+
|
|
210
|
+
| Language | Imports | Named Bindings | Exports | Heritage | Type Annotations | Constructor Inference | Config | Frameworks | Entry Points |
|
|
211
|
+
|----------|---------|----------------|---------|----------|-----------------|---------------------|--------|------------|-------------|
|
|
212
|
+
| TypeScript | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
213
|
+
| JavaScript | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ | ✓ | ✓ |
|
|
214
|
+
| Python | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
215
|
+
| Java | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ |
|
|
216
|
+
| Kotlin | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ |
|
|
217
|
+
| C# | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
218
|
+
| Go | ✓ | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
219
|
+
| Rust | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ |
|
|
220
|
+
| PHP | ✓ | ✓ | ✓ | — | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
221
|
+
| Ruby | ✓ | — | ✓ | ✓ | — | ✓ | — | ✓ | ✓ |
|
|
222
|
+
| Swift | — | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
223
|
+
| C | — | — | ✓ | — | ✓ | ✓ | — | ✓ | ✓ |
|
|
224
|
+
| C++ | — | — | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ |
|
|
225
|
+
|
|
226
|
+
**Imports** — cross-file import resolution · **Named Bindings** — `import { X as Y }` / re-export tracking · **Exports** — public/exported symbol detection · **Heritage** — class inheritance, interfaces, mixins · **Type Annotations** — explicit type extraction for receiver resolution · **Constructor Inference** — infer receiver type from constructor calls (`self`/`this` resolution included for all languages) · **Config** — language toolchain config parsing (tsconfig, go.mod, etc.) · **Frameworks** — AST-based framework pattern detection · **Entry Points** — entry point scoring heuristics
|
|
227
|
+
|
|
228
|
+
## Agent Skills
|
|
229
|
+
|
|
230
|
+
GitNexus ships with skill files that teach AI agents how to use the tools effectively:
|
|
231
|
+
|
|
232
|
+
- **Exploring** — Navigate unfamiliar code using the knowledge graph
|
|
233
|
+
- **Debugging** — Trace bugs through call chains
|
|
234
|
+
- **Impact Analysis** — Analyze blast radius before changes
|
|
235
|
+
- **Refactoring** — Plan safe refactors using dependency mapping
|
|
236
|
+
|
|
237
|
+
Installed automatically by both `gitnexus analyze` (per-repo) and `gitnexus setup` (global).
|
|
238
|
+
|
|
239
|
+
## Requirements
|
|
240
|
+
|
|
241
|
+
- Node.js >= 18
|
|
242
|
+
- Git repository (uses git for commit tracking)
|
|
243
|
+
|
|
244
|
+
## Privacy
|
|
245
|
+
|
|
246
|
+
- All processing happens locally on your machine
|
|
247
|
+
- No code is sent to any server
|
|
248
|
+
- Index stored in `.gitnexus/` inside your repo (gitignored)
|
|
249
|
+
- Global registry at `~/.gitnexus/` stores only paths and metadata
|
|
250
|
+
|
|
251
|
+
## Web UI
|
|
252
|
+
|
|
253
|
+
GitNexus also has a browser-based UI at [gitnexus.vercel.app](https://gitnexus.vercel.app) — 100% client-side, your code never leaves the browser.
|
|
254
|
+
|
|
255
|
+
**Local Backend Mode:** Run `gitnexus serve` and open the web UI locally — it auto-detects the server and shows all your indexed repos, with full AI chat support. No need to re-upload or re-index. The agent's tools (Cypher queries, search, code navigation) route through the backend HTTP API automatically.
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
[PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
260
|
+
|
|
261
|
+
Free for non-commercial use. Contact for commercial licensing.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Context Generator
|
|
3
|
+
*
|
|
4
|
+
* Creates AGENTS.md and CLAUDE.md with full inline GitNexus context.
|
|
5
|
+
* AGENTS.md is the standard read by Cursor, Windsurf, OpenCode, Cline, etc.
|
|
6
|
+
* CLAUDE.md is for Claude Code which only reads that file.
|
|
7
|
+
*/
|
|
8
|
+
import { type GeneratedSkillInfo } from './skill-gen.js';
|
|
9
|
+
interface RepoStats {
|
|
10
|
+
files?: number;
|
|
11
|
+
nodes?: number;
|
|
12
|
+
edges?: number;
|
|
13
|
+
communities?: number;
|
|
14
|
+
clusters?: number;
|
|
15
|
+
processes?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generate AI context files after indexing
|
|
19
|
+
*/
|
|
20
|
+
export declare function generateAIContextFiles(repoPath: string, _storagePath: string, projectName: string, stats: RepoStats, generatedSkills?: GeneratedSkillInfo[]): Promise<{
|
|
21
|
+
files: string[];
|
|
22
|
+
}>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Context Generator
|
|
3
|
+
*
|
|
4
|
+
* Creates AGENTS.md and CLAUDE.md with full inline GitNexus context.
|
|
5
|
+
* AGENTS.md is the standard read by Cursor, Windsurf, OpenCode, Cline, etc.
|
|
6
|
+
* CLAUDE.md is for Claude Code which only reads that file.
|
|
7
|
+
*/
|
|
8
|
+
import fs from 'fs/promises';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
// ESM equivalent of __dirname
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
const GITNEXUS_START_MARKER = '<!-- gitnexus:start -->';
|
|
15
|
+
const GITNEXUS_END_MARKER = '<!-- gitnexus:end -->';
|
|
16
|
+
/**
|
|
17
|
+
* Generate the full GitNexus context content.
|
|
18
|
+
*
|
|
19
|
+
* Design principles (learned from real agent behavior and industry research):
|
|
20
|
+
* - Inline critical workflows — skills are skipped 56% of the time (Vercel eval data)
|
|
21
|
+
* - Use RFC 2119 language (MUST, NEVER, ALWAYS) — models follow imperative rules
|
|
22
|
+
* - Three-tier boundaries (Always/When/Never) — proven to change model behavior
|
|
23
|
+
* - Keep under 120 lines — adherence degrades past 150 lines
|
|
24
|
+
* - Exact tool commands with parameters — vague directives get ignored
|
|
25
|
+
* - Self-review checklist — forces model to verify its own work
|
|
26
|
+
*/
|
|
27
|
+
function generateGitNexusContent(projectName, stats, generatedSkills) {
|
|
28
|
+
const generatedRows = (generatedSkills && generatedSkills.length > 0)
|
|
29
|
+
? generatedSkills.map(s => `| Work in the ${s.label} area (${s.symbolCount} symbols) | \`.claude/skills/generated/${s.name}/SKILL.md\` |`).join('\n')
|
|
30
|
+
: '';
|
|
31
|
+
const skillsTable = `| Task | Read this skill file |
|
|
32
|
+
|------|---------------------|
|
|
33
|
+
| Understand architecture / "How does X work?" | \`.claude/skills/gitnexus/gitnexus-exploring/SKILL.md\` |
|
|
34
|
+
| Blast radius / "What breaks if I change X?" | \`.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md\` |
|
|
35
|
+
| Trace bugs / "Why is X failing?" | \`.claude/skills/gitnexus/gitnexus-debugging/SKILL.md\` |
|
|
36
|
+
| Rename / extract / split / refactor | \`.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md\` |
|
|
37
|
+
| Tools, resources, schema reference | \`.claude/skills/gitnexus/gitnexus-guide/SKILL.md\` |
|
|
38
|
+
| Index, status, clean, wiki CLI commands | \`.claude/skills/gitnexus/gitnexus-cli/SKILL.md\` |${generatedRows ? '\n' + generatedRows : ''}`;
|
|
39
|
+
return `${GITNEXUS_START_MARKER}
|
|
40
|
+
# GitNexus — Code Intelligence
|
|
41
|
+
|
|
42
|
+
This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
|
43
|
+
|
|
44
|
+
> If any GitNexus tool warns the index is stale, run \`npx gitnexus analyze\` in terminal first.
|
|
45
|
+
|
|
46
|
+
## Always Do
|
|
47
|
+
|
|
48
|
+
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run \`gitnexus_impact({target: "symbolName", direction: "upstream"})\` and report the blast radius (direct callers, affected processes, risk level) to the user.
|
|
49
|
+
- **MUST run \`gitnexus_detect_changes()\` before committing** to verify your changes only affect expected symbols and execution flows.
|
|
50
|
+
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
|
|
51
|
+
- When exploring unfamiliar code, use \`gitnexus_query({query: "concept"})\` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
|
|
52
|
+
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use \`gitnexus_context({name: "symbolName"})\`.
|
|
53
|
+
|
|
54
|
+
## When Debugging
|
|
55
|
+
|
|
56
|
+
1. \`gitnexus_query({query: "<error or symptom>"})\` — find execution flows related to the issue
|
|
57
|
+
2. \`gitnexus_context({name: "<suspect function>"})\` — see all callers, callees, and process participation
|
|
58
|
+
3. \`READ gitnexus://repo/${projectName}/process/{processName}\` — trace the full execution flow step by step
|
|
59
|
+
4. For regressions: \`gitnexus_detect_changes({scope: "compare", base_ref: "main"})\` — see what your branch changed
|
|
60
|
+
|
|
61
|
+
## When Refactoring
|
|
62
|
+
|
|
63
|
+
- **Renaming**: MUST use \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` first. Review the preview — graph edits are safe, text_search edits need manual review. Then run with \`dry_run: false\`.
|
|
64
|
+
- **Extracting/Splitting**: MUST run \`gitnexus_context({name: "target"})\` to see all incoming/outgoing refs, then \`gitnexus_impact({target: "target", direction: "upstream"})\` to find all external callers before moving code.
|
|
65
|
+
- After any refactor: run \`gitnexus_detect_changes({scope: "all"})\` to verify only expected files changed.
|
|
66
|
+
|
|
67
|
+
## Never Do
|
|
68
|
+
|
|
69
|
+
- NEVER edit a function, class, or method without first running \`gitnexus_impact\` on it.
|
|
70
|
+
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
|
|
71
|
+
- NEVER rename symbols with find-and-replace — use \`gitnexus_rename\` which understands the call graph.
|
|
72
|
+
- NEVER commit changes without running \`gitnexus_detect_changes()\` to check affected scope.
|
|
73
|
+
|
|
74
|
+
## Tools Quick Reference
|
|
75
|
+
|
|
76
|
+
| Tool | When to use | Command |
|
|
77
|
+
|------|-------------|---------|
|
|
78
|
+
| \`query\` | Find code by concept | \`gitnexus_query({query: "auth validation"})\` |
|
|
79
|
+
| \`context\` | 360-degree view of one symbol | \`gitnexus_context({name: "validateUser"})\` |
|
|
80
|
+
| \`impact\` | Blast radius before editing | \`gitnexus_impact({target: "X", direction: "upstream"})\` |
|
|
81
|
+
| \`detect_changes\` | Pre-commit scope check | \`gitnexus_detect_changes({scope: "staged"})\` |
|
|
82
|
+
| \`rename\` | Safe multi-file rename | \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` |
|
|
83
|
+
| \`cypher\` | Custom graph queries | \`gitnexus_cypher({query: "MATCH ..."})\` |
|
|
84
|
+
|
|
85
|
+
## Impact Risk Levels
|
|
86
|
+
|
|
87
|
+
| Depth | Meaning | Action |
|
|
88
|
+
|-------|---------|--------|
|
|
89
|
+
| d=1 | WILL BREAK — direct callers/importers | MUST update these |
|
|
90
|
+
| d=2 | LIKELY AFFECTED — indirect deps | Should test |
|
|
91
|
+
| d=3 | MAY NEED TESTING — transitive | Test if critical path |
|
|
92
|
+
|
|
93
|
+
## Resources
|
|
94
|
+
|
|
95
|
+
| Resource | Use for |
|
|
96
|
+
|----------|---------|
|
|
97
|
+
| \`gitnexus://repo/${projectName}/context\` | Codebase overview, check index freshness |
|
|
98
|
+
| \`gitnexus://repo/${projectName}/clusters\` | All functional areas |
|
|
99
|
+
| \`gitnexus://repo/${projectName}/processes\` | All execution flows |
|
|
100
|
+
| \`gitnexus://repo/${projectName}/process/{name}\` | Step-by-step execution trace |
|
|
101
|
+
|
|
102
|
+
## Self-Check Before Finishing
|
|
103
|
+
|
|
104
|
+
Before completing any code modification task, verify:
|
|
105
|
+
1. \`gitnexus_impact\` was run for all modified symbols
|
|
106
|
+
2. No HIGH/CRITICAL risk warnings were ignored
|
|
107
|
+
3. \`gitnexus_detect_changes()\` confirms changes match expected scope
|
|
108
|
+
4. All d=1 (WILL BREAK) dependents were updated
|
|
109
|
+
|
|
110
|
+
## Keeping the Index Fresh
|
|
111
|
+
|
|
112
|
+
After committing code changes, the GitNexus index becomes stale. Re-run analyze to update it:
|
|
113
|
+
|
|
114
|
+
\`\`\`bash
|
|
115
|
+
npx gitnexus analyze
|
|
116
|
+
\`\`\`
|
|
117
|
+
|
|
118
|
+
If the index previously included embeddings, preserve them by adding \`--embeddings\`:
|
|
119
|
+
|
|
120
|
+
\`\`\`bash
|
|
121
|
+
npx gitnexus analyze --embeddings
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
To check whether embeddings exist, inspect \`.gitnexus/meta.json\` — the \`stats.embeddings\` field shows the count (0 means no embeddings). **Running analyze without \`--embeddings\` will delete any previously generated embeddings.**
|
|
125
|
+
|
|
126
|
+
> Claude Code users: A PostToolUse hook handles this automatically after \`git commit\` and \`git merge\`.
|
|
127
|
+
|
|
128
|
+
## CLI
|
|
129
|
+
|
|
130
|
+
${skillsTable}
|
|
131
|
+
|
|
132
|
+
${GITNEXUS_END_MARKER}`;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if a file exists
|
|
136
|
+
*/
|
|
137
|
+
async function fileExists(filePath) {
|
|
138
|
+
try {
|
|
139
|
+
await fs.access(filePath);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create or update GitNexus section in a file
|
|
148
|
+
* - If file doesn't exist: create with GitNexus content
|
|
149
|
+
* - If file exists without GitNexus section: append
|
|
150
|
+
* - If file exists with GitNexus section: replace that section
|
|
151
|
+
*/
|
|
152
|
+
async function upsertGitNexusSection(filePath, content) {
|
|
153
|
+
const exists = await fileExists(filePath);
|
|
154
|
+
if (!exists) {
|
|
155
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
156
|
+
return 'created';
|
|
157
|
+
}
|
|
158
|
+
const existingContent = await fs.readFile(filePath, 'utf-8');
|
|
159
|
+
// Check if GitNexus section already exists
|
|
160
|
+
const startIdx = existingContent.indexOf(GITNEXUS_START_MARKER);
|
|
161
|
+
const endIdx = existingContent.indexOf(GITNEXUS_END_MARKER);
|
|
162
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
163
|
+
// Replace existing section
|
|
164
|
+
const before = existingContent.substring(0, startIdx);
|
|
165
|
+
const after = existingContent.substring(endIdx + GITNEXUS_END_MARKER.length);
|
|
166
|
+
const newContent = before + content + after;
|
|
167
|
+
await fs.writeFile(filePath, newContent.trim() + '\n', 'utf-8');
|
|
168
|
+
return 'updated';
|
|
169
|
+
}
|
|
170
|
+
// Append new section
|
|
171
|
+
const newContent = existingContent.trim() + '\n\n' + content + '\n';
|
|
172
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
173
|
+
return 'appended';
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Install GitNexus skills to .claude/skills/gitnexus/
|
|
177
|
+
* Works natively with Claude Code, Cursor, and GitHub Copilot
|
|
178
|
+
*/
|
|
179
|
+
async function installSkills(repoPath) {
|
|
180
|
+
const skillsDir = path.join(repoPath, '.claude', 'skills', 'gitnexus');
|
|
181
|
+
const installedSkills = [];
|
|
182
|
+
// Skill definitions bundled with the package
|
|
183
|
+
const skills = [
|
|
184
|
+
{
|
|
185
|
+
name: 'gitnexus-exploring',
|
|
186
|
+
description: 'Use when the user asks how code works, wants to understand architecture, trace execution flows, or explore unfamiliar parts of the codebase. Examples: "How does X work?", "What calls this function?", "Show me the auth flow"',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'gitnexus-debugging',
|
|
190
|
+
description: 'Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: "Why is X failing?", "Where does this error come from?", "Trace this bug"',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'gitnexus-impact-analysis',
|
|
194
|
+
description: 'Use when the user wants to know what will break if they change something, or needs safety analysis before editing code. Examples: "Is it safe to change X?", "What depends on this?", "What will break?"',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'gitnexus-refactoring',
|
|
198
|
+
description: 'Use when the user wants to rename, extract, split, move, or restructure code safely. Examples: "Rename this function", "Extract this into a module", "Refactor this class", "Move this to a separate file"',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'gitnexus-guide',
|
|
202
|
+
description: 'Use when the user asks about GitNexus itself — available tools, how to query the knowledge graph, MCP resources, graph schema, or workflow reference. Examples: "What GitNexus tools are available?", "How do I use GitNexus?"',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'gitnexus-cli',
|
|
206
|
+
description: 'Use when the user needs to run GitNexus CLI commands like analyze/index a repo, check status, clean the index, generate a wiki, or list indexed repos. Examples: "Index this repo", "Reanalyze the codebase", "Generate a wiki"',
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
for (const skill of skills) {
|
|
210
|
+
const skillDir = path.join(skillsDir, skill.name);
|
|
211
|
+
const skillPath = path.join(skillDir, 'SKILL.md');
|
|
212
|
+
try {
|
|
213
|
+
// Create skill directory
|
|
214
|
+
await fs.mkdir(skillDir, { recursive: true });
|
|
215
|
+
// Try to read from package skills directory
|
|
216
|
+
const packageSkillPath = path.join(__dirname, '..', '..', 'skills', `${skill.name}.md`);
|
|
217
|
+
let skillContent;
|
|
218
|
+
try {
|
|
219
|
+
skillContent = await fs.readFile(packageSkillPath, 'utf-8');
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// Fallback: generate minimal skill content
|
|
223
|
+
skillContent = `---
|
|
224
|
+
name: ${skill.name}
|
|
225
|
+
description: ${skill.description}
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
# ${skill.name.charAt(0).toUpperCase() + skill.name.slice(1)}
|
|
229
|
+
|
|
230
|
+
${skill.description}
|
|
231
|
+
|
|
232
|
+
Use GitNexus tools to accomplish this task.
|
|
233
|
+
`;
|
|
234
|
+
}
|
|
235
|
+
await fs.writeFile(skillPath, skillContent, 'utf-8');
|
|
236
|
+
installedSkills.push(skill.name);
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
// Skip on error, don't fail the whole process
|
|
240
|
+
console.warn(`Warning: Could not install skill ${skill.name}:`, err);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return installedSkills;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Generate AI context files after indexing
|
|
247
|
+
*/
|
|
248
|
+
export async function generateAIContextFiles(repoPath, _storagePath, projectName, stats, generatedSkills) {
|
|
249
|
+
const content = generateGitNexusContent(projectName, stats, generatedSkills);
|
|
250
|
+
const createdFiles = [];
|
|
251
|
+
// Create AGENTS.md (standard for Cursor, Windsurf, OpenCode, Cline, etc.)
|
|
252
|
+
const agentsPath = path.join(repoPath, 'AGENTS.md');
|
|
253
|
+
const agentsResult = await upsertGitNexusSection(agentsPath, content);
|
|
254
|
+
createdFiles.push(`AGENTS.md (${agentsResult})`);
|
|
255
|
+
// Create CLAUDE.md (for Claude Code)
|
|
256
|
+
const claudePath = path.join(repoPath, 'CLAUDE.md');
|
|
257
|
+
const claudeResult = await upsertGitNexusSection(claudePath, content);
|
|
258
|
+
createdFiles.push(`CLAUDE.md (${claudeResult})`);
|
|
259
|
+
// Install skills to .claude/skills/gitnexus/
|
|
260
|
+
const installedSkills = await installSkills(repoPath);
|
|
261
|
+
if (installedSkills.length > 0) {
|
|
262
|
+
createdFiles.push(`.claude/skills/gitnexus/ (${installedSkills.length} skills)`);
|
|
263
|
+
}
|
|
264
|
+
return { files: createdFiles };
|
|
265
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analyze Command
|
|
3
|
+
*
|
|
4
|
+
* Indexes a repository and stores the knowledge graph in .gitnexus/
|
|
5
|
+
*/
|
|
6
|
+
export interface AnalyzeOptions {
|
|
7
|
+
force?: boolean;
|
|
8
|
+
embeddings?: boolean;
|
|
9
|
+
skills?: boolean;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const analyzeCommand: (inputPath?: string, options?: AnalyzeOptions) => Promise<void>;
|