utils

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package utils provides utility functions for the list-codes CLI tool.

This package contains core functionality for:

  • Project language detection and classification
  • File system operations and directory traversal
  • Source code collection and processing
  • Markdown output generation
  • Configuration management
  • Logging and debugging utilities

The package is organized into several modules:

  • config.go: Configuration constants and variables
  • language.go: Language detection and classification
  • file.go: File system operations and filtering
  • process.go: Source code processing and Markdown generation
  • log.go: Logging utilities
  • utils.go: General utility functions

Key features include:

  • Automatic programming language detection based on signature files and extensions
  • Configurable file size limits and filtering
  • Support for include/exclude path patterns
  • Test file detection and exclusion
  • Comprehensive directory structure generation
  • Dependency file collection and processing

Index

Constants

View Source
const DependencyFilesCategory = "Dependency Files"
View Source
const MaxFileSizeBytesDefault = 1024 * 1024 // 1MB
View Source
const MaxStructureDepthDefault = 7

Variables

View Source
var ASSET_EXTENSIONS = map[string]struct{}{

	".png":  {},
	".jpg":  {},
	".jpeg": {},
	".gif":  {},
	".bmp":  {},
	".ico":  {},
	".tiff": {},
	".webp": {},
	".avif": {},
	".heic": {},

	".svg": {},

	".woff":  {},
	".woff2": {},
	".ttf":   {},
	".otf":   {},
	".eot":   {},

	".mp3":  {},
	".wav":  {},
	".ogg":  {},
	".aac":  {},
	".flac": {},
	".m4a":  {},

	".mp4":  {},
	".avi":  {},
	".mov":  {},
	".webm": {},
	".mkv":  {},
	".wmv":  {},

	".zip": {},
	".tar": {},
	".gz":  {},
	".rar": {},
	".7z":  {},
	".bz2": {},

	".pdf":  {},
	".docx": {},
	".xlsx": {},
	".pptx": {},

	".exe": {},
	".dmg": {},
	".deb": {},
	".rpm": {},
}

ASSET_EXTENSIONS contains file extensions for asset files that should be excluded by default. These files are typically not useful for source code analysis.

View Source
var DefaultExcludeNames = map[string]struct{}{
	"node_modules": {},
	"vendor":       {},
	"target":       {},
	"build":        {},
	"dist":         {},
	"__pycache__":  {},
	"env":          {},
	"venv":         {},

	"assets":  {},
	"static":  {},
	"images":  {},
	"media":   {},
	"uploads": {},
}

DefaultExcludeNames contains default directory and file names to exclude by name. Dotfiles are now handled by a general rule in shouldSkipDir

View Source
var EXCLUDE_TEST_DIRS = []string{
	"/test/",
	"/tests/",
	"/spec/",
	"/specs/",
	"/__tests__/",
	"/__test__/",
	"/testing/",
	"/fixtures/",
	"/mocks/",
	"/e2e/",
	"/integration/",
	"/unit/",
	"test/",
	"tests/",
	"spec/",
	"specs/",
}

EXCLUDE_TEST_DIRS contains directory paths for identifying test files. The IsTestFile function checks if the file's path contains any of these strings.

View Source
var EXCLUDE_TEST_KEYWORDS = []string{
	"test",
	"spec",
	"e2e",
	"benchmark",
	"bench",
	"mock",
	"fixture",
}

EXCLUDE_TEST_KEYWORDS contains keywords for identifying test files. The IsTestFile function performs a case-insensitive check against the base filename.

View Source
var EXCLUDE_TEST_PATTERNS = []string{
	"_test.go",
	"_spec.rb",
	".test.js",
	".spec.js",
	".test.jsx",
	".spec.jsx",
	".test.ts",
	".spec.ts",
	".test.tsx",
	".spec.tsx",
	".test.py",
	".spec.py",
	"Test.java",
	"Tests.java",
	"IT.java",
	".test.php",
	".spec.php",
	"_test.rb",
	".test.cs",
	".spec.cs",
	"Test.cs",
	"Tests.cs",
	".test.cpp",
	".spec.cpp",
	".test.c",
	".spec.c",
	".test.rs",
	".spec.rs",
	".test.kt",
	".spec.kt",
	"Test.kt",
	".test.swift",
	".spec.swift",
	"Test.swift",
	".t.sol",
	".test.sol",
	".spec.sol",
}

EXCLUDE_TEST_PATTERNS contains specific filename patterns to identify test files. This is useful for conventions not easily caught by keywords alone.

View Source
var EXTENSIONS = map[string][]string{
	"Python":     {".py", ".pyw"},
	"Ruby":       {".rb", ".rbw"},
	"Javascript": {".js", ".jsx", ".mjs", ".cjs"},
	"Typescript": {".ts", ".tsx", ".mts", ".cts"},
	"Go":         {".go"},
	"Swift":      {".swift"},
	"Kotlin":     {".kt", ".kts"},
	"Rust":       {".rs"},
	"SQL":        {".sql"},
	"HTML": {".html", ".htm", ".rhtml", ".erb", ".haml", ".slim",

		".hbs", ".handlebars", ".mustache", ".hjs",
		".ejs", ".pug", ".jade",
		".njk", ".nunjucks",
		".twig", ".liquid",
		".tmpl", ".tpl", ".gohtml",

		".djhtml", ".jinja", ".jinja2", ".j2",

		".cshtml", ".vbhtml",

		".jsp", ".jspx",

		".aspx", ".ascx", ".master",

		".eex", ".heex", ".leex",

		".ftl", ".vm",

		".dust", ".eta", ".vash"},
	"CSS":          {".css", ".scss", ".sass", ".less", ".styl"},
	"Lua":          {".lua"},
	"C":            {".c", ".h"},
	"C++":          {".cpp", ".hpp", ".cxx", ".hxx", ".cc", ".hh", ".c++", ".h++"},
	"Java":         {".java"},
	"PHP":          {".php", ".phtml", ".php3", ".php4", ".php5"},
	"C#":           {".cs", ".csx"},
	"F#":           {".fs", ".fsi", ".fsx"},
	"VB.NET":       {".vb"},
	"Scala":        {".scala", ".sc"},
	"Clojure":      {".clj", ".cljs", ".cljc"},
	"Haskell":      {".hs", ".lhs"},
	"Erlang":       {".erl", ".hrl"},
	"Elixir":       {".ex", ".exs"},
	"Dart":         {".dart"},
	"R":            {".r", ".R"},
	"Perl":         {".pl", ".pm", ".perl"},
	"Objective-C":  {".m", ".mm"},
	"Pascal":       {".pas", ".pp"},
	"Fortran":      {".f", ".f90", ".f95", ".f03", ".f08"},
	"COBOL":        {".cob", ".cbl"},
	"Ada":          {".ada", ".adb", ".ads"},
	"Lisp":         {".lisp", ".lsp", ".cl"},
	"Scheme":       {".scm", ".ss"},
	"Prolog":       {".pl", ".pro"},
	"MATLAB":       {".m"},
	"Octave":       {".m"},
	"Julia":        {".jl"},
	"Zig":          {".zig"},
	"D":            {".d"},
	"Nim":          {".nim"},
	"Crystal":      {".cr"},
	"Groovy":       {".groovy", ".gvy"},
	"PowerShell":   {".ps1", ".psm1", ".psd1"},
	"Bash":         {".bash"},
	"Zsh":          {".zsh"},
	"Fish":         {".fish"},
	"Tcl":          {".tcl"},
	"Vim":          {".vim"},
	"Emacs Lisp":   {".el"},
	"Protobuf/Buf": {".proto"},
	"Markdown":     {".md"},
	"MDX":          {".mdx"},
	"Vue":          {".vue"},
	"Svelte":       {".svelte"},
	"Solidity":     {".sol"},
	"YAML":         {".yaml", ".yml"},
	"JSON":         {".json"},
	"XML":          {".xml", ".xsd", ".xsl"},
	"Shell":        {".sh"},
	"Dockerfile":   {"Dockerfile"},
	"TOML":         {".toml"},
	"Gradle":       {".gradle", ".gradle.kts"},
	"INI":          {".ini", ".cfg"},
	"Properties":   {".properties"},
	"Makefile":     {"Makefile", "makefile", ".mk"},
	"CMake":        {".cmake", "CMakeLists.txt"},
	"Terraform":    {".tf", ".tfvars"},
	"HCL":          {".hcl"},
	"GraphQL":      {".graphql", ".gql"},
	"Jupyter":      {".ipynb"},
	"LaTeX":        {".tex", ".latex"},
	"Regex":        {".regex"},
	"Diff":         {".diff", ".patch"},
	"Log":          {".log"},
	"CSV":          {".csv"},
	"TSV":          {".tsv"},
	"WebAssembly":  {".wat", ".wasm"},
	"Assembly":     {".asm", ".s"},
}

EXTENSIONS maps file extensions to programming languages for detection.

View Source
var MaxFileSizeBytes int64 = MaxFileSizeBytesDefault
View Source
var PROJECT_SIGNATURES = map[string][]string{
	"Go":         {"go.mod"},
	"Ruby":       {"Gemfile"},
	"Javascript": {"package.json", "node_modules"},
	"Typescript": {"tsconfig.json"},
	"Python":     {"requirements.txt", "setup.py", "pyproject.toml", "Pipfile"},
	"Rust":       {"Cargo.toml"},
	"SQL":        {".sql"},
	"HTML": {".html", ".htm", ".rhtml", ".erb", ".haml", ".slim",

		".hbs", ".handlebars", ".mustache", ".hjs",
		".ejs", ".pug", ".jade",
		".njk", ".nunjucks",
		".twig", ".liquid",
		".tmpl", ".tpl", ".gohtml",

		".djhtml", ".jinja", ".jinja2", ".j2",

		".cshtml", ".vbhtml",

		".jsp", ".jspx",

		".eex", ".heex", ".leex",

		".dust", ".eta", ".vash"},
	"CSS":          {".css", ".scss", ".sass"},
	"Lua":          {".lua"},
	"C":            {".c"},
	"C++":          {".cpp", ".hpp", ".cxx", ".hxx", ".cc", ".hh", ".h"},
	"Java":         {"build.gradle", "settings.gradle", "pom.xml"},
	"PHP":          {"composer.json"},
	"C#":           {".csproj", ".sln", "project.json"},
	"F#":           {".fsproj"},
	"VB.NET":       {".vbproj"},
	"Scala":        {"build.sbt"},
	"Clojure":      {"project.clj", "deps.edn"},
	"Haskell":      {".cabal", "stack.yaml"},
	"Erlang":       {"rebar.config"},
	"Elixir":       {"mix.exs"},
	"Dart":         {"pubspec.yaml"},
	"R":            {"DESCRIPTION"},
	"Julia":        {"Project.toml"},
	"Swift":        {"Package.swift"},
	"Kotlin":       {"build.gradle.kts"},
	"Groovy":       {"build.gradle"},
	"CMake":        {"CMakeLists.txt"},
	"Terraform":    {"main.tf"},
	"Protobuf/Buf": {".proto", "buf.yaml"},
	"Markdown":     {"README.md"},
	"MDX":          {".mdx"},
	"Vue":          {".vue"},
	"Svelte":       {".svelte"},
	"Solidity":     {"hardhat.config.js", "hardhat.config.ts", "truffle-config.js", "foundry.toml"},
}

PROJECT_SIGNATURES contains signature files/directories for detecting project languages/frameworks.

View Source
var PromptTemplates = PromptTemplatesEN

PromptTemplates contains predefined prompt templates for LLM analysis (legacy, kept for compatibility)

View Source
var PromptTemplatesEN = map[string]string{
	"explain": `Please analyze the following codebase and explain the following aspects:

1. **Project purpose and main functionality**
2. **Architecture and design patterns**
3. **Key components and their roles**
4. **Technology stack and dependencies**
5. **Code structure and organization**

Please provide a clear and concise explanation that can be understood by non-technical people.`,

	"find-bugs": `Please analyze the following codebase in detail and identify potential bugs, errors, and issues:

1. **Logic errors and implementation problems**
2. **Memory leaks and performance issues**
3. **Error handling deficiencies**
4. **Type safety issues**
5. **Boundary value and edge case handling problems**
6. **Race conditions and thread safety issues**

For each issue, please provide the location, detailed description, and suggested fixes.`,

	"refactor": `Please analyze the following codebase and identify refactoring opportunities:

1. **Code duplication elimination**
2. **Function and class responsibility separation**
3. **Naming improvements**
4. **Breaking down overly complex functions**
5. **Design pattern application opportunities**
6. **Performance improvements**

For each suggestion, please indicate current problems, benefits after improvement, and implementation priority.`,

	"security": `Please analyze the following codebase from a security perspective and identify vulnerabilities and security risks:

1. **Input validation deficiencies**
2. **SQL injection and XSS possibilities**
3. **Authentication and authorization issues**
4. **Sensitive information exposure**
5. **Inappropriate permission settings**
6. **Encryption and hashing deficiencies**

For each issue, please provide risk level, impact scope, and countermeasures.`,

	"optimize": `Please analyze the following codebase and identify performance optimization opportunities:

1. **Computational complexity improvement possibilities**
2. **Memory usage optimization**
3. **I/O operation efficiency**
4. **Caching utilization opportunities**
5. **Parallel processing introduction possibilities**
6. **Potential bottlenecks**

For each optimization, please indicate current problems, improvement proposals, and expected effects.`,

	"test": `Please analyze the following codebase and provide testing improvement suggestions:

1. **Areas lacking test coverage**
2. **Missing edge case tests**
3. **Need for integration tests**
4. **Test code quality improvements**
5. **Mock and stub utilization opportunities**
6. **Test automation improvements**

Please also provide specific test case examples.`,

	"document": `Please analyze the following codebase and provide documentation improvement suggestions:

1. **Missing specifications and design documents**
2. **Complex processes lacking comments**
3. **API documentation completeness**
4. **README.md improvement points**
5. **Code documentation quality**
6. **Need for usage examples and tutorials**

Please provide suggestions from both user and developer perspectives.`,

	"migrate": `Please analyze the following codebase and provide technology stack migration and update suggestions:

1. **Updating old libraries and frameworks**
2. **More appropriate technology choice suggestions**
3. **Language version updates**
4. **Architecture modernization**
5. **Migration risks and benefits**
6. **Gradual migration plans**

Please evaluate migration complexity and benefits.`,

	"scale": `Please analyze the following codebase from a scalability perspective:

1. **Current architecture limitations**
2. **Potential bottlenecks**
3. **Horizontal and vertical scaling support**
4. **Database design scalability**
5. **Microservices architecture possibilities**
6. **Load balancing mechanisms**

Please provide improvement suggestions for large-scale operations.`,

	"maintain": `Please analyze the maintainability of the following codebase and provide improvement suggestions:

1. **Code readability improvements**
2. **Inter-module dependency organization**
3. **Configuration management improvements**
4. **Log and error handling standardization**
5. **Development workflow improvements**
6. **Technical debt identification and resolution**

Please provide suggestions from a long-term maintainability perspective.`,

	"api-design": `Please analyze the API design of the following codebase and provide improvement suggestions:

1. **RESTful design validity**
2. **Endpoint design consistency**
3. **Request and response formats**
4. **Error response standardization**
5. **Versioning strategy**
6. **API documentation completeness**

Please provide suggestions aimed at user-friendly and consistent API design.`,

	"patterns": `Please analyze the following codebase and suggest applicable design patterns:

1. **Current code structure issues**
2. **Applicable GoF patterns**
3. **Architecture pattern utilization**
4. **Functional programming patterns**
5. **Concurrency patterns**
6. **Error handling patterns**

Please indicate application locations and expected effects for each pattern.`,

	"review": `Please conduct a comprehensive code review of the following codebase:

1. **Coding standard compliance**
2. **Best practice application**
3. **Code quality and consistency**
4. **Potential improvement points**
5. **Team development challenges**
6. **Technologies and methods to learn**

Please provide constructive and specific feedback.`,

	"architecture": `Please analyze the architecture of the following codebase and provide evaluation and suggestions:

1. **Current architecture characteristics and evaluation**
2. **Layered structure validity**
3. **Dependency directions**
4. **Module division appropriateness**
5. **Design principle (SOLID, etc.) application status**
6. **Future extensibility support**

Please provide specific suggestions for better architecture.`,

	"deploy": `Please analyze the deployment and operational aspects of the following codebase and provide improvement suggestions:

1. **CI/CD pipeline improvements**
2. **Deployment strategy optimization**
3. **Monitoring and logging enhancements**
4. **Incident response and rollback**
5. **Environment management improvements**
6. **Operational automation opportunities**

Please provide practical improvement proposals from a DevOps perspective.`,
}

PromptTemplatesEN contains English versions of prompt templates

View Source
var PromptTemplatesJA = map[string]string{
	"explain": `以下のプロジェクトのコードベースを分析し、以下の項目について説明してください:

1. **プロジェクトの目的と主要機能**
2. **アーキテクチャと設計パターン**
3. **主要なコンポーネントとその役割**
4. **技術スタックと依存関係**
5. **コードの構造と組織化**

技術的でない人にも理解できるよう、簡潔で分かりやすい説明をお願いします。`,

	"find-bugs": `以下のコードベースを詳細に分析し、潜在的なバグ、エラー、問題を特定してください:

1. **論理エラーや実装上の問題**
2. **メモリリークや性能問題**
3. **エラーハンドリングの不備**
4. **型安全性の問題**
5. **境界値やエッジケースの処理不備**
6. **競合状態やスレッドセーフティの問題**

各問題について、該当箇所、問題の詳細、修正案を提示してください。`,

	"refactor": `以下のコードベースを分析し、リファクタリングの機会を特定してください:

1. **コードの重複排除**
2. **関数やクラスの責任分離**
3. **命名の改善**
4. **複雑すぎる関数の分割**
5. **デザインパターンの適用機会**
6. **パフォーマンス改善**

各提案について、現在の問題点、改善後の利点、実装の優先度を示してください。`,

	"security": `以下のコードベースをセキュリティの観点から分析し、脆弱性やセキュリティリスクを特定してください:

1. **入力値検証の不備**
2. **SQLインジェクションやXSSの可能性**
3. **認証・認可の問題**
4. **機密情報の露出**
5. **不適切な権限設定**
6. **暗号化やハッシュ化の不備**

各問題について、リスクレベル、影響範囲、対策方法を提示してください。`,

	"optimize": `以下のコードベースを分析し、パフォーマンス最適化の機会を特定してください:

1. **計算量の改善可能性**
2. **メモリ使用量の最適化**
3. **I/O操作の効率化**
4. **キャッシュの活用機会**
5. **並列処理の導入可能性**
6. **ボトルネックとなりうる箇所**

各最適化について、現在の問題、改善案、期待される効果を示してください。`,

	"test": `以下のコードベースを分析し、テストの改善提案を行ってください:

1. **テストカバレッジの不足箇所**
2. **エッジケースのテスト不足**
3. **統合テストの必要性**
4. **テストコードの品質改善**
5. **モックやスタブの活用機会**
6. **テストの自動化改善**

具体的なテストケースの例も合わせて提示してください。`,

	"document": `以下のコードベースを分析し、ドキュメントの改善提案を行ってください:

1. **不足している仕様書や設計書**
2. **コメントが不足している複雑な処理**
3. **API仕様書の充実度**
4. **README.mdの改善点**
5. **コード内ドキュメントの品質**
6. **使用例やチュートリアルの必要性**

ユーザーと開発者の両方の視点から提案してください。`,

	"migrate": `以下のコードベースを分析し、技術スタックの移行や更新の提案を行ってください:

1. **古いライブラリやフレームワークの更新**
2. **より適切な技術選択の提案**
3. **言語バージョンのアップデート**
4. **アーキテクチャの現代化**
5. **移行に伴うリスクと利点**
6. **段階的な移行計画**

移行の複雑さとメリットを評価してください。`,

	"scale": `以下のコードベースをスケーラビリティの観点から分析してください:

1. **現在のアーキテクチャの限界**
2. **ボトルネックとなりうる箇所**
3. **水平・垂直スケーリングの対応**
4. **データベース設計の拡張性**
5. **マイクロサービス化の可能性**
6. **負荷分散の仕組み**

大規模運用に向けた改善提案を行ってください。`,

	"maintain": `以下のコードベースの保守性を分析し、改善提案を行ってください:

1. **コードの可読性向上**
2. **モジュール間の依存関係整理**
3. **設定管理の改善**
4. **ログとエラー処理の標準化**
5. **開発ワークフローの改善**
6. **技術的負債の特定と対処**

長期的な保守性向上の観点から提案してください。`,

	"api-design": `以下のコードベースのAPI設計を分析し、改善提案を行ってください:

1. **RESTful設計の妥当性**
2. **エンドポイント設計の一貫性**
3. **リクエスト・レスポンス形式**
4. **エラーレスポンスの標準化**
5. **バージョニング戦略**
6. **APIドキュメントの充実度**

使いやすく一貫性のあるAPI設計を目指した提案をしてください。`,

	"patterns": `以下のコードベースを分析し、適用可能なデザインパターンを提案してください:

1. **現在のコード構造の問題点**
2. **適用可能なGoFパターン**
3. **アーキテクチャパターンの活用**
4. **関数型プログラミングパターン**
5. **並行処理パターン**
6. **エラーハンドリングパターン**

各パターンの適用箇所と期待される効果を示してください。`,

	"review": `以下のコードベースに対して包括的なコードレビューを実施してください:

1. **コーディング規約の遵守状況**
2. **ベストプラクティスの適用度**
3. **コードの品質と一貫性**
4. **潜在的な改善点**
5. **チーム開発での課題**
6. **学習すべき技術や手法**

建設的で具体的なフィードバックを提供してください。`,

	"architecture": `以下のコードベースのアーキテクチャを分析し、評価・提案を行ってください:

1. **現在のアーキテクチャの特徴と評価**
2. **レイヤード構造の妥当性**
3. **依存関係の方向性**
4. **モジュール分割の適切性**
5. **設計原則(SOLID等)の適用状況**
6. **将来の拡張性への対応**

より良いアーキテクチャに向けた具体的な提案をしてください。`,

	"deploy": `以下のコードベースのデプロイメントと運用面を分析し、改善提案を行ってください:

1. **CI/CDパイプラインの改善**
2. **デプロイメント戦略の最適化**
3. **監視とログの充実**
4. **障害対応とロールバック**
5. **環境管理の改善**
6. **運用自動化の機会**

DevOpsの観点から実践的な改善案を提示してください。`,
}

PromptTemplatesJA contains Japanese versions of prompt templates

View Source
var TotalMaxFileSizeBytes int64 = 0 // 0 means no limit

Functions

func CollectReadmeFiles

func CollectReadmeFiles(folderAbs string, includePaths, excludeNames, excludePaths map[string]struct{}, debug bool, gi *GitIgnoreMatcher) string

CollectReadmeFiles collects README.md files in the project and returns their content in Markdown format.

func FormatWithPrompt

func FormatWithPrompt(prompt, content string) string

FormatWithPrompt formats the output content with the specified prompt. If prompt is empty, returns the content as-is.

func GenerateDirectoryStructure

func GenerateDirectoryStructure(startPath string, maxDepth int, debugMode bool, includePaths, excludeNames, excludePaths map[string]struct{}, includeTests bool, gi *GitIgnoreMatcher) string

GenerateDirectoryStructure generates the project directory structure in Markdown format.

func GetAvailablePrompts added in v0.2.3

func GetAvailablePrompts() []string

GetAvailablePrompts returns a list of available prompt template names

func GetCurrentLanguage

func GetCurrentLanguage() language.Tag

GetCurrentLanguage returns the current language tag

func GetHelpMessages

func GetHelpMessages() (string, string, string)

GetHelpMessages returns localized help messages

func GetLanguageByExtension

func GetLanguageByExtension(fileNameOrExtension string) string

GetLanguageByExtension detects the language from a file name or extension.

func GetPrompt

func GetPrompt(promptParam string, debugMode bool) (string, error)

GetPrompt returns the prompt text based on the given prompt parameter. If the prompt parameter matches a predefined template name, it returns that template. If the prompt parameter appears to be a file path, it reads the prompt from the file. Otherwise, it returns the prompt parameter as-is (custom prompt).

func GetPromptI18n

func GetPromptI18n(promptParam string, debugMode bool) (string, error)

GetPromptI18n returns the appropriate prompt template based on current language

func GetPromptTemplateNames

func GetPromptTemplateNames() []string

GetPromptTemplateNames returns a sorted list of available prompt template names

func InitI18n

func InitI18n(debugMode bool)

InitI18n initializes the internationalization system

func IsAssetFile added in v0.5.0

func IsAssetFile(filePath string, debug bool) bool

IsAssetFile determines if the specified file path is an asset file that should be excluded. Asset files include images, fonts, media files, archives, and other binary files that are not useful for source code analysis.

func IsJapanese

func IsJapanese() bool

IsJapanese returns true if the current language is Japanese

func IsTestFile

func IsTestFile(filePath string, debug bool) bool

IsTestFile determines if the specified file path is a test file. It now accepts a debug flag to print its reasoning.

func ParseSize added in v0.4.0

func ParseSize(sizeStr string) (int64, error)

ParseSize parses human-readable size strings like "1k", "1m", "1g" and returns bytes. Supports formats: 123, 123b, 123k, 123m, 123g (case insensitive)

func PrintDebug

func PrintDebug(msg string, debug bool)

PrintDebug prints debug messages.

func PrintError

func PrintError(msg string)

PrintError prints error messages.

func PrintWarning

func PrintWarning(msg string, debug bool)

PrintWarning prints warning messages.

func ProcessSourceFiles

func ProcessSourceFiles(folderAbs string, maxDepth int, includePaths, excludeNames, excludePaths map[string]struct{}, debug bool, includeTests bool, gi *GitIgnoreMatcher) string

ProcessSourceFiles processes source files and generates a Markdown summary.

func SaveToMarkdown

func SaveToMarkdown(content string, outputPath string) error

SaveToMarkdown saves the generated Markdown content to a file or outputs it to stdout.

func SetLanguage

func SetLanguage(lang string, debugMode bool) error

SetLanguage sets the language explicitly (overrides auto-detection)

func T

func T(englishText, japaneseText string) string

T returns the appropriate translation based on current language

Types

type GitIgnoreMatcher added in v0.5.0

type GitIgnoreMatcher struct {
	// contains filtered or unexported fields
}

GitIgnoreMatcher provides functionality to match paths against .gitignore rules

func NewGitIgnoreMatcher added in v0.5.0

func NewGitIgnoreMatcher(root string) (*GitIgnoreMatcher, error)

NewGitIgnoreMatcher creates a new GitIgnoreMatcher by walking the repository and loading all .gitignore files found in the directory hierarchy.

func (*GitIgnoreMatcher) Match added in v0.5.0

func (m *GitIgnoreMatcher) Match(path string) bool

Match checks if the given path should be ignored according to .gitignore rules. It returns true if the path should be ignored, false otherwise. The function applies Git's precedence rules: closer .gitignore files take precedence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL