Metadata-Version: 2.4
Name: mycelium-map
Version: 0.1.0
Summary: Static analysis tool that maps the hidden network of connections in codebases
Project-URL: Homepage, https://github.com/ScottRBK/mycelium
Project-URL: Repository, https://github.com/ScottRBK/mycelium
Author-email: Scott <scott.raisbeck1985@gmail.com>
License-Expression: MIT
Requires-Python: >=3.12
Requires-Dist: click>=8.1
Requires-Dist: networkx>=3.4
Requires-Dist: rich>=13.0
Requires-Dist: tree-sitter-c-sharp>=0.23.1
Requires-Dist: tree-sitter-c>=0.23.4
Requires-Dist: tree-sitter-cpp>=0.23.4
Requires-Dist: tree-sitter-go>=0.23.4
Requires-Dist: tree-sitter-java>=0.23.5
Requires-Dist: tree-sitter-javascript>=0.23.1
Requires-Dist: tree-sitter-python>=0.23.6
Requires-Dist: tree-sitter-rust>=0.23.2
Requires-Dist: tree-sitter-typescript>=0.23.2
Requires-Dist: tree-sitter>=0.24.0
Description-Content-Type: text/markdown

# Mycelium

Static analysis CLI that maps the connections in a source code repository. Produces a single JSON file containing file structure, symbols, imports, call graph, community clusters, and execution flows.

## Install

```bash
uv sync
```

## Usage

```bash
mycelium analyze <path>                          # Analyse a repo
mycelium analyze <path> -o output.json           # Custom output path
mycelium analyze <path> --verbose                # Show phase timing breakdown
mycelium analyze <path> --quiet                  # No terminal output
mycelium analyze <path> -l cs,ts                 # Only analyse C# and TypeScript
mycelium analyze <path> --exclude vendor,legacy  # Skip directories
mycelium analyze <path> --resolution 1.5         # Louvain resolution (higher = more communities)
mycelium analyze <path> --max-processes 50       # Limit execution flows
mycelium analyze <path> --max-depth 8            # Limit BFS trace depth
```

Default output file: `<repo-name>.mycelium.json`

## Supported Languages

| Language | Extensions |
|---|---|
| C# | `.cs` |
| VB.NET | `.vb` (requires grammar build) |
| TypeScript | `.ts`, `.tsx` |
| JavaScript | `.js`, `.jsx`, `.mjs`, `.cjs` |
| Python | `.py` |
| Java | `.java` |
| Go | `.go` |
| Rust | `.rs` |
| C | `.c`, `.h` |
| C++ | `.cpp`, `.cc`, `.cxx`, `.hpp`, `.hxx`, `.hh` |

## Output Schema

The JSON output contains these top-level sections:

### `metadata`

```json
{
  "repo_name": "my-project",
  "repo_path": "/absolute/path",
  "analysed_at": "2026-02-05T18:33:12Z",
  "mycelium_version": "0.1.0",
  "commit_hash": "a1b2c3d4e5f6",
  "analysis_duration_ms": 42.3,
  "phase_timings": { "structure": 0.004, "parsing": 0.001, ... }
}
```

### `stats`

Summary counts: `files`, `folders`, `symbols`, `calls`, `imports`, `communities`, `processes`, and a `languages` breakdown by file count.

### `structure`

File tree with language, size, and line counts.

```json
{
  "files": [{ "path": "src/main.cs", "language": "cs", "size": 1024, "lines": 45 }],
  "folders": [{ "path": "src/", "file_count": 3 }]
}
```

### `symbols`

Every extracted symbol: classes, methods, interfaces, functions, structs, enums, etc.

```json
{
  "id": "sym_0001",
  "name": "UserController",
  "type": "Class",
  "file": "Controllers/UserController.cs",
  "line": 8,
  "visibility": "public",
  "exported": true,
  "parent": "MyApp.Controllers",
  "language": "cs"
}
```

Symbol types: `Class`, `Function`, `Method`, `Interface`, `Struct`, `Enum`, `Namespace`, `Property`, `Constructor`, `Module`, `Record`, `Delegate`, `TypeAlias`, `Constant`, `Trait`, `Impl`, `Macro`, `Typedef`, `Annotation`.

Visibility: `public`, `private`, `internal`, `protected`.

### `imports`

Three categories of dependency edges:

```json
{
  "file_imports": [{ "from": "Controller.cs", "to": "Service.cs", "statement": "using MyApp.Services" }],
  "project_references": [{ "from_project": "Web.csproj", "to_project": "Core.csproj", "ref_type": "ProjectReference" }],
  "package_references": [{ "project": "Web.csproj", "package": "Newtonsoft.Json", "version": "13.0.1" }]
}
```

Project and package references are extracted from `.csproj`/`.vbproj` files.

### `calls`

Call graph edges with three-tier confidence scoring:

```json
{
  "from": "sym_0004",
  "to": "sym_0015",
  "confidence": 0.9,
  "tier": "A",
  "reason": "import-resolved",
  "line": 17
}
```

| Tier | Confidence | Meaning |
|------|-----------|---------|
| A | 0.9 | Callee found in an imported file |
| B | 0.85 | Callee found in the same file |
| C | 0.5 | Unique fuzzy match across the codebase |
| C | 0.3 | Ambiguous fuzzy match (multiple candidates) |

### `communities`

Clusters of symbols that frequently call each other, detected via Louvain algorithm.

```json
{
  "id": "community_0",
  "label": "Absence",
  "members": ["sym_0004", "sym_0015", "sym_0016"],
  "cohesion": 0.8,
  "primary_language": "cs"
}
```

### `processes`

Execution flows traced from entry points (controllers, handlers, main functions) via BFS through the call graph.

```json
{
  "id": "process_0",
  "entry": "sym_0004",
  "terminal": "sym_0016",
  "steps": ["sym_0004", "sym_0015", "sym_0016"],
  "type": "intra_community",
  "total_confidence": 0.765
}
```

`type` is `intra_community` when all steps are in the same community, or `cross_community` when the flow spans multiple.

`total_confidence` is the product of all edge confidences along the path.

## Tests

```bash
uv run pytest           # 229 tests
uv run pytest -v        # Verbose output
```
