Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

3.7 KB
Raw Blame
#!/usr/bin/env python3
# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""
Constants for CodeRepositoryParser.

This file contains all constant definitions used by CodeRepositoryParser
to keep the main code file clean and focused on logic.
"""

MPEG_TS_EXTENSION_ALIAS = "mpegts"
TYPESCRIPT_MPEG_TS_EXTENSION = ".ts"

# Directories to ignore in code repositories
IGNORE_DIRS = {
    ".git",
    ".svn",
    ".hg",
    ".idea",
    ".vscode",
    "__pycache__",
    "node_modules",
    "venv",
    ".venv",
    "env",
    ".env",
    "dist",
    "build",
    "target",
    "bin",
    "obj",
    ".DS_Store",
}

# Extensions to ignore (binary, huge files, and non-text content)
IGNORE_EXTENSIONS = {
    # Binary/compiled files
    ".pyc",
    ".pyo",
    ".pyd",
    ".so",
    ".dll",
    ".dylib",
    ".exe",
    ".bin",
    ".iso",
    ".img",
    ".db",
    ".sqlite",
    ".sqlite3",
    # Archive formats
    ".zip",
    ".tar",
    ".gz",
    ".rar",
    ".7z",
    # Image formats (explicitly mentioned as exception in README.md)
    ".jpg",
    ".jpeg",
    ".png",
    ".gif",
    ".bmp",
    ".ico",
    # Document formats
    ".pdf",
    ".doc",
    ".docx",
    ".ppt",
    ".pptx",
    ".xls",
    ".xlsx",
    # Java compiled files
    ".class",
    ".jar",
    ".war",
    ".ear",
    # Video formats (non-text content per README.md requirements)
    ".mp4",
    ".mov",
    ".avi",
    ".webm",
    ".mkv",
    ".flv",
    ".wmv",
    ".mpg",
    ".mpeg",
    # Audio formats (non-text content per README.md requirements)
    ".mp3",
    ".wav",
    ".m4a",
    ".flac",
    ".aac",
    ".ogg",
    ".wma",
    ".mid",
    ".midi",
}

# Code file extensions for file type detection
CODE_EXTENSIONS = {
    ".py",
    ".pyi",
    ".java",
    ".cpp",
    ".cc",
    ".c",
    ".cu",
    ".cuh",
    ".h",
    ".hpp",
    ".inl",
    ".cs",
    ".js",
    ".ts",
    ".jsx",
    ".tsx",
    ".go",
    ".rs",
    ".rb",
    ".php",
    ".swift",
    ".kt",
    ".scala",
    ".m",
    ".hs",
    ".lua",
    ".pl",
    ".r",
    ".sql",
    ".sh",
    ".bash",
    ".zsh",
    ".fish",
    ".ps1",
    ".bat",
    ".cmd",
    ".yml",
    ".yaml",
    ".toml",
    ".json",
    ".xml",
    ".html",
    ".htm",
    ".css",
    ".scss",
    ".less",
    ".sass",
    ".vue",
    ".svelte",
    ".elm",
    ".clj",
    ".cljs",
    ".edn",
    ".ex",
    ".exs",
    ".erl",
    ".hrl",
    ".fs",
    ".fsx",
    ".fsi",
    ".dart",
    ".groovy",
    ".gradle",
    ".julia",
    ".nim",
    ".odin",
    ".zig",
    ".v",
    ".sv",
    ".vhd",
    ".vhdl",
    ".tex",
    ".bib",
    ".asm",
    ".s",
    ".inc",
    ".make",
    ".mk",
    ".cmake",
    ".proto",
    ".thrift",
    ".avdl",
    ".graphql",
    ".gql",
    ".prisma",
}

# Documentation file extensions for file type detection
DOCUMENTATION_EXTENSIONS = {
    ".md",
    ".markdown",
    ".mdown",
    ".mkd",
    ".txt",
    ".text",
    ".rst",
    ".adoc",
    ".asciidoc",
    ".org",
    ".texi",
    ".texinfo",
    ".wiki",
    ".conf",
}

# File type constants for consistent return values
FILE_TYPE_CODE = "code"
FILE_TYPE_DOCUMENTATION = "documentation"
FILE_TYPE_OTHER = "other"
FILE_TYPE_BINARY = "binary"

# Text file extensions for encoding detection and conversion
# These are additional text file extensions not already in CODE_EXTENSIONS or DOCUMENTATION_EXTENSIONS
ADDITIONAL_TEXT_EXTENSIONS = {
    ".ini",
    ".cfg",
    ".conf",
    ".properties",
    ".toml",
    ".json",
    ".jsonl",
    ".yaml",
    ".yml",
    ".xml",
    ".csv",
    ".tsv",
    ".log",
    ".gitignore",
    ".dockerignore",
    ".editorconfig",
    ".eslintrc",
    ".prettierrc",
    ".babelrc",
    ".npmrc",
    ".yarnrc",
    ".env",
    ".env.example",
    ".lock",
    ".in",
}