{"id":16391767,"url":"https://github.com/williamfzc/gossiphs","last_synced_at":"2026-01-26T05:02:04.487Z","repository":{"id":238882354,"uuid":"783642905","full_name":"williamfzc/gossiphs","owner":"williamfzc","description":"\"Zero setup\" \u0026 \"Blazingly fast\" general code file relationship analysis. With Python \u0026 Rust. Based on tree-sitter and git analysis. Support MCP and ready for AI🤖","archived":false,"fork":false,"pushed_at":"2026-01-22T15:52:31.000Z","size":264,"stargazers_count":95,"open_issues_count":8,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-23T05:56:25.027Z","etag":null,"topics":["code-analysis","code-navigation","codebase","file-index","graph","kge","knowledge-graph","lsp","mcp","python","sourcecode-analysis"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamfzc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-08T09:40:23.000Z","updated_at":"2026-01-22T15:52:35.000Z","dependencies_parsed_at":"2024-05-19T06:29:25.269Z","dependency_job_id":"b29bb332-312b-49e0-bdfe-2dfb44c84042","html_url":"https://github.com/williamfzc/gossiphs","commit_stats":{"total_commits":178,"total_committers":2,"mean_commits":89.0,"dds":0.005617977528089901,"last_synced_commit":"d299b29c7ceb9ef742ede151342dfe871ee5d57a"},"previous_names":["williamfzc/gossiphs"],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/williamfzc/gossiphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fgossiphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fgossiphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fgossiphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fgossiphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamfzc","download_url":"https://codeload.github.com/williamfzc/gossiphs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamfzc%2Fgossiphs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28767013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T03:54:34.369Z","status":"ssl_error","status_checked_at":"2026-01-26T03:54:33.031Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-analysis","code-navigation","codebase","file-index","graph","kge","knowledge-graph","lsp","mcp","python","sourcecode-analysis"],"created_at":"2024-10-11T04:47:17.964Z","updated_at":"2026-01-26T05:02:04.481Z","avatar_url":"https://github.com/williamfzc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gossiphs = Gossip Graphs\n\n\u003e [!TIP]\n\u003e We provide an easy-to-use Python SDK and support for MCP (Model Context Protocol), allowing you to seamlessly\n\u003e integrate it with your AI.\n\u003e\n\u003e See [Gossiphs MCP Server](./mcp/README.md)\n\n![Crates.io Version](https://img.shields.io/crates/v/gossiphs)\n[![RealWorld Test](https://github.com/williamfzc/gossiphs/actions/workflows/cargo-test.yml/badge.svg)](https://github.com/williamfzc/gossiphs/actions/workflows/cargo-test.yml)\n\n\"Zero setup\" \u0026 \"Blazingly fast\" general code file relationship analysis. With Python \u0026 Rust. Based on tree-sitter and\ngit analysis. Support MCP and ready for AI🤖\n\n## What's it\n\nGossiphs can analyze the history of commits and the relationships between variable declarations and references in your\ncodebase to obtain a relationship diagram of the code files.\n\nIt also allows developers to query the content declared in each file, thereby enabling free search for its references\nthroughout the entire codebase to achieve more complex analysis.\n\n```mermaid\ngraph TD\n    A[main.py] --- S1[func_main] --- B[module_a.py]\n    A --- S2[Handler] --- C[module_b.py]\n    B --- S3[func_util] --- D[utils.py]\n    C --- S3[func_util] --- D\n    A --- S4[func_init] --- E[module_c.py]\n    E --- S5[process] --- F[module_d.py]\n    E --- S6[Processor] --- H[module_e.py]\n    H --- S7[transform] --- I[module_f.py]\n    I --- S3[func_util] --- D\n```\n\n## Supported Languages\n\nWe are expanding language support based\non [Tree-Sitter Query](https://tree-sitter.github.io/tree-sitter/code-navigation-systems), which isn't too costly.\nIf you're interested, you can check out the [contribution](#contribution) section.\n\n| Language   | Status |\n|------------|--------|\n| Rust       | ✅      |\n| Python     | ✅      |\n| TypeScript | ✅      |\n| JavaScript | ✅      |\n| Golang     | ✅      |\n| Java       | ✅      |\n| Kotlin     | ✅      |\n| Swift      | ✅      |\n| C#         | ✅      |\n\nYou can see the [rule files](./src/rule.rs) here.\n\n## Usage\n\n### Python\n\n```bash\npip install gossiphs\n```\n\nAnalyze your codebase with networkx within 30 lines:\n\n```python\nimport networkx as nx\nfrom gossiphs import GraphConfig, create_graph, Graph\n\nconfig = GraphConfig()\nconfig.project_path = \"../..\"\ngraph: Graph = create_graph(config)\n\nnx_graph = nx.DiGraph()\n\nfor each_file in graph.files():\n    nx_graph.add_node(each_file, metadata=graph.file_metadata(each_file))\n\n    related_files = graph.related_files(each_file)\n    for each_related_file in related_files:\n        related_symbols = set(each_symbol.symbol.name for each_symbol in each_related_file.related_symbols)\n\n        nx_graph.add_edge(\n            each_file,\n            each_related_file.name,\n            related_symbols=list(related_symbols)\n        )\n\nprint(f\"NetworkX graph created with {nx_graph.number_of_nodes()} nodes and {nx_graph.number_of_edges()} edges.\")\n\nfor src, dest, data in nx_graph.edges(data=True):\n    print(f\"{src} -\u003e {dest}, related symbols: {data['related_symbols']}\")\n```\n\nOutput:\n\n```text\nNetworkX graph created with 13 nodes and 27 edges.\nsrc/server.rs -\u003e src/main.rs, related symbols: ['server_main']\nsrc/main.rs -\u003e src/graph.rs, related symbols: ['default']\nsrc/main.rs -\u003e examples/mini.rs, related symbols: ['default']\nsrc/main.rs -\u003e src/server.rs, related symbols: ['main']\nsrc/symbol.rs -\u003e src/graph.rs, related symbols: ['link_file_to_symbol', 'list_references', 'list_references_by_definition', 'id', 'enhance_symbol_to_symbol', 'add_file', 'add_symbol', 'list_definitions', 'list_symbols', 'new', 'link_symbol_to_symbol', 'get_symbol']\n...\n```\n\nMore [examples](./py_wrapper/examples) can be found here.\n\n### Others\n\nWe also provide a CLI and additional usage options, making it easy to directly export CSV files or start an HTTP\nservice.\n\nSee [usage page](./docs/usage.md).\n\n## Goal \u0026 Motivation\n\n\u003e [!TIP]\n\u003e Create a file relationship index with:\n\u003e - low cost\n\u003e - acceptable accuracy\n\u003e - high versatility for nearly any code repository\n\u003e\n\nCode navigation is a fascinating subject that plays a pivotal role in various domains, such as:\n\n- Guiding the context during the development process within an IDE.\n- Facilitating more convenient code browsing on websites.\n- Analyzing the impact of code changes in Continuous Integration (CI) systems.\n- ...\n\nIn the past, I endeavored to apply [LSP/LSIF technologies](https://lsif.dev/) and techniques\nlike [Github's Stack-Graphs](https://dcreager.net/talks/stack-graphs/) to impact analysis, encountering different\nchallenges along the way. For our needs, a method akin to Stack-Graphs aligns most closely with our expectations.\nHowever, the challenges are evident: it requires crafting highly language-specific rules, which is a considerable\ninvestment for us, given that we do not require such high precision data.\n\nWe attempt to make some trade-offs on the challenges currently faced by\nstack-graphs to achieve our expected goals to a certain extent:\n\n- Zero repo-specific configuration: It can be applied to most languages and repositories without additional\n  configuration.\n- Low extension cost: adding rules for languages is not high.\n- Acceptable precision: We have sacrificed a certain level of precision, but we also hope that it remains at an\n  acceptable level.\n\n## How it works\n\nGossiphs constructs a graph that interconnects symbols of definitions and references.\n\n1. Extract imports and exports: Identify the imports and exports of each file.\n2. Connect nodes: Establish connections between potential definition and reference nodes.\n3. Refine edges with commit histories: Utilize commit histories to refine the relationships between nodes.\n\nUnlike stack-graphs, we have omitted the highly complex scope analysis and instead opted to refine our edges using\ncommit histories.\nThis approach significantly reduces the complexity of rule writing, as the rules only need to specify which types of\nsymbols should be exported or imported for each file.\n\nWhile there is undoubtedly a trade-off in precision, the benefits are clear:\n\n1. Minimal impact on accuracy: In practical scenarios, the loss of precision is not as significant as one might expect.\n2. Commit history relevance: The use of commit history to reflect the influence between code segments aligns well with\n   our objectives.\n3. Language support: We can easily support the vast majority of programming languages, meeting the analysis needs of\n   various types of repositories.\n\n## Precision\n\n\u003e Static analysis has its limits, such as dynamic binding.\n\u003e Therefore, it is unlikely to achieve the level of accuracy provided by LSP, but it can offer sufficient accuracy in\n\u003e the areas where it is primarily used.\n\nThe method we use to demonstrate accuracy is to compare the results with those of LSP/LSIF. It must be admitted that\nstatic inference is almost impossible to obtain all reference relationships like LSP.\n\nYou can further combine your own needs and use other methods such as tfidf to process the results to meet more complex\nrequirements.\n\n| Repo                             | Coverage of LSP Edges by Gossiphs |\n|----------------------------------|-----------------------------------|\n| https://github.com/go-gorm/gorm  | 442/499 = 88.5 %                  |\n| https://github.com/gin-gonic/gin | 238/252 = 94.4%                   |\n\n## Contribution\n\nThe project is still in a very early and experimental stage. If you are interested, please leave your thoughts through\nan issue. In the short term, we hope to build better support for more languages.\n\nYou just need to:\n\n1. Edit rules in [src/rule.rs](src/rule.rs)\n2. Test it in [src/extractor.rs](src/extractor.rs)\n3. Try it with your repo in [src/graph.rs](src/graph.rs)\n\n[Tree-sitter Playground](https://tree-sitter.github.io/tree-sitter/playground) is a good helper.\n\n## License\n\n[Apache 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fgossiphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamfzc%2Fgossiphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamfzc%2Fgossiphs/lists"}