Skip to content

Commit 03d0a29

Browse files
authored
Merge pull request #142 from FSoft-AI4Code/feat/zig-vue-autotools
Add Zig and Vue SFC analyzers, Autotools build artifacts
2 parents d8a80eb + 8904740 commit 03d0a29

19 files changed

Lines changed: 2339 additions & 25 deletions

‎CHANGELOG.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,34 @@ uses [Semantic Versioning](https://semver.org/).
4444
to directories through the module path in `go.mod` (and local `replace`
4545
directives), and standard-library or third-party calls are dropped.
4646
`_test.go` files and `vendor/` are skipped.
47+
- **Zig analyzer.** Functions, containers (`struct`, `enum`, `union`,
48+
`opaque`), their member functions (`Point.add`), and generic type functions
49+
(`fn List(comptime T: type) type { return struct {...}; }`) become
50+
components. Edges cover calls (plain, `alias.fn()`, and method calls on
51+
`Self`, parameters, and locals whose type can be inferred), `T{...}`
52+
literals, and types named in parameters, return types, fields, and
53+
annotated locals. `@import("x.zig")` aliases and re-exports
54+
(`const T = @import("x.zig").T;`) resolve to the file that declares the
55+
name, as do module names that the root `build.zig` registers with
56+
`addModule`; `std`, `builtin`, and third-party packages are dropped. `test`
57+
blocks and `zig-cache/`, `.zig-cache/`, `zig-out/` are skipped, `build.zig`
58+
is also a build artifact, and `build.zig.zon` is a manifest.
59+
- **Vue single-file components.** Each `.vue` file becomes a component
60+
(`ArticleList.vue::ArticleList`), and its options-API members (`methods`,
61+
`computed`, `watch`, lifecycle hooks such as `mounted` or `setup`) become
62+
its methods. `<script>` and `<script setup>` blocks go through the
63+
JavaScript or TypeScript analyzer (`lang="ts"`), keeping the `.vue` file's
64+
line numbers. Edges link a component to the `.vue` files and modules it
65+
imports (relative paths and the `@/` alias), to the components its template
66+
uses (`<article-preview>` or `<ArticlePreview>`), and to the members and
67+
script functions its template expressions call or bind.
68+
- **Autotools build files.** `configure.ac`, `Makefile.am` (and other `*.am`),
69+
`acinclude.m4`, and macros under `m4/` are build artifacts. A `Makefile.am`
70+
gets a unit per library or program it builds (`libfoo.la`), linked to the
71+
sources in its `_SOURCES` lists, and `SUBDIRS` links to the sub-directory
72+
`Makefile.am`s. A `configure.ac` gets a unit per `AC_ARG_ENABLE` /
73+
`AC_ARG_WITH` option and links to the `Makefile.am`s that `AC_CONFIG_FILES`
74+
generates.
4775

4876
### Changed
4977

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ Full list in the [CHANGELOG](./CHANGELOG.md).
119119
## Features
120120

121121
**Languages.** Python, Java, JavaScript, TypeScript, C, C++, C#, Kotlin,
122-
PHP, Ruby, Scala, Rust, Dart (Flutter-aware), Go.
122+
PHP, Ruby, Scala, Rust, Dart (Flutter-aware), Go, Zig, Vue (single-file
123+
components).
123124

124125
**Hierarchical decomposition.** The dependency graph is clustered into a
125126
module tree, recursively, so a 1.4M-line repository gets the same treatment

‎codewiki/cli/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def cli(ctx):
2020
2121
AI agents write the documentation from your dependency graph. Supports
2222
Python, Java, JavaScript, TypeScript, C, C++, C#, Kotlin, PHP, Ruby,
23-
Scala, Rust, Dart, and Go.
23+
Scala, Rust, Dart, Go, Zig, and Vue.
2424
"""
2525
# Ensure context object exists
2626
ctx.ensure_object(dict)

‎codewiki/cli/utils/repo_validator.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
".rs", # Rust
3737
".dart", # Dart
3838
".go", # Go
39+
".zig", # Zig
40+
".vue", # Vue single-file components
3941
}
4042

4143

@@ -67,7 +69,7 @@ def validate_repository(repo_path: Path) -> tuple[Path, list[tuple[str, int]]]:
6769
raise RepositoryError(
6870
f"No supported code files found in {repo_path}\n\n"
6971
"CodeWiki supports: Python, Java, JavaScript, TypeScript, C, C++, C#, Kotlin, PHP, "
70-
"Ruby, Scala, Rust, Dart, Go\n\n"
72+
"Ruby, Scala, Rust, Dart, Go, Zig, Vue\n\n"
7173
"Please navigate to a code repository or specify a custom directory:\n"
7274
" cd /path/to/your/project\n"
7375
" codewiki generate"

‎codewiki/cli/utils/validation.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def detect_supported_languages(directory: Path) -> list[tuple[str, int]]:
170170
"Rust": [".rs"],
171171
"Dart": [".dart"],
172172
"Go": [".go"],
173+
"Zig": [".zig"],
174+
"Vue": [".vue"],
173175
}
174176

175177
# Directories to exclude from counting

‎codewiki/mcp/tools/analysis.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ def _detect_via_mtime(
231231
".rs",
232232
".dart",
233233
".go",
234+
".zig",
235+
".vue",
234236
}
235237

236238
changed: list[str] = []

‎codewiki/src/be/dependency_analyzer/analysis/analysis_service.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _filter_supported_languages(self, code_files: list[dict]) -> list[dict]:
340340
Filter code files to only include supported languages.
341341
342342
Supports Python, JavaScript, TypeScript, Java, C#, C, C++, PHP, Ruby, Kotlin,
343-
Scala, Rust, Dart, and Go.
343+
Scala, Rust, Dart, Go, Zig, and Vue single-file components.
344344
"""
345345
supported_languages = {
346346
"python",
@@ -357,6 +357,8 @@ def _filter_supported_languages(self, code_files: list[dict]) -> list[dict]:
357357
"kotlin",
358358
"scala",
359359
"dart",
360+
"zig",
361+
"vue",
360362
}
361363

362364
return [
@@ -382,6 +384,8 @@ def _get_supported_languages(self) -> list[str]:
382384
"rust",
383385
"dart",
384386
"go",
387+
"zig",
388+
"vue",
385389
]
386390

387391
def _cleanup_repository(self, temp_dir: str):

‎codewiki/src/be/dependency_analyzer/analysis/call_graph_analyzer.py‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ def _analyze_code_file(self, repo_dir: str, file_info: dict):
287287
self._analyze_dart_file(file_path, content, repo_dir)
288288
elif language == "go":
289289
self._analyze_go_file(file_path, content, repo_dir)
290+
elif language == "zig":
291+
self._analyze_zig_file(file_path, content, repo_dir)
292+
elif language == "vue":
293+
self._analyze_vue_file(file_path, content, repo_dir)
290294
# else:
291295
# logger.warning(
292296
# f"Unsupported language for call graph analysis: {language} for file {file_path}"
@@ -612,6 +616,54 @@ def _analyze_dart_file(self, file_path: str, content: str, repo_dir: str):
612616
except Exception:
613617
logger.exception(f"Failed to analyze Dart file {file_path}")
614618

619+
def _analyze_zig_file(self, file_path: str, content: str, repo_dir: str):
620+
"""
621+
Analyze Zig file using tree-sitter based analyzer.
622+
623+
Args:
624+
file_path: Path to the Zig file
625+
content: File content string
626+
repo_dir: Repository base directory
627+
"""
628+
from codewiki.src.be.dependency_analyzer.analyzers.zig import analyze_zig_file
629+
630+
try:
631+
functions, relationships = analyze_zig_file(str(file_path), content, repo_path=repo_dir)
632+
633+
for func in functions:
634+
func_id = func.id if func.id else f"{file_path}:{func.name}"
635+
self.functions[func_id] = func
636+
637+
self.call_relationships.extend(relationships)
638+
except Exception:
639+
logger.exception(f"Failed to analyze Zig file {file_path}")
640+
641+
def _analyze_vue_file(self, file_path: str, content: str, repo_dir: str):
642+
"""
643+
Analyze a Vue single-file component.
644+
645+
The <script> blocks go through the JavaScript/TypeScript analyzers; the
646+
component itself, its options-API members, and its template usage are
647+
added by the Vue analyzer.
648+
649+
Args:
650+
file_path: Path to the .vue file
651+
content: File content string
652+
repo_dir: Repository base directory
653+
"""
654+
from codewiki.src.be.dependency_analyzer.analyzers.vue import analyze_vue_file
655+
656+
try:
657+
functions, relationships = analyze_vue_file(str(file_path), content, repo_path=repo_dir)
658+
659+
for func in functions:
660+
func_id = func.id if func.id else f"{file_path}:{func.name}"
661+
self.functions[func_id] = func
662+
663+
self.call_relationships.extend(relationships)
664+
except Exception:
665+
logger.exception(f"Failed to analyze Vue file {file_path}")
666+
615667
def _analyze_go_file(self, file_path: str, content: str, repo_dir: str):
616668
"""
617669
Analyze Go file using tree-sitter based analyzer.
@@ -1094,6 +1146,10 @@ def _generate_visualization_data(self) -> dict:
10941146
node_classes.append("lang-dart")
10951147
elif file_ext == ".go":
10961148
node_classes.append("lang-go")
1149+
elif file_ext == ".zig":
1150+
node_classes.append("lang-zig")
1151+
elif file_ext == ".vue":
1152+
node_classes.append("lang-vue")
10971153

10981154
cytoscape_elements.append(
10991155
{

0 commit comments

Comments
 (0)