# How to customize ByteInsight

## How ByteInsight Works

ByteInsight uses configuration files that associate file extensions to a set of attributes including: Is it binary? Does it have interesting content? What kind of content? (project, code, markup, etc.) To what kind of language is it associated? How to tell content lines apart from comments and blank lines? How to ignore blocks that are not part of the language? (comments or strings)

## Configuration file format

The ByteInsight configuration files have extension cfg and contain a json with the following format:

#### **Sample configuration file:**

```scala
{
  "Name": "C Sharp",
  "ContentType": "Code",
  "SourceExtensions": [
    "cs"
  ],
  "BinaryExtensions": [

  ],
  "CaseSensitive": "true",
  "SeparatorChars": " \t\r\n",
  "SymbolChars": "-+/*{}[]()<>~!#$%^&=`'\".,;:?\\|",
  "WordChars": "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàâãåæçèêìîðñòôõøùûýþÿ",
  "IgnoreBlockDescriptors": [
    {
      "Start": "/*",
      "End": "*/",
      "Ignore": [],
      "Kind": "Comment"
    },
    {
      "Start": "\"",
      "End": "\"",
      "Ignore": [ "\\\"", "\\\\" ],
      "Kind": "Content"
    }
  ],
  "LineComment": "//",
  "Keywords": [
    "abstract",
    "as",
    "async",
    "await",
    ...
    "partial",
    "yield"
  ]
}

```

#### **File Elements:**

* **Name**: The Technology name that will apply for the files with the specified extensions. \
  E.g.: "Java, "C#", "Python", etc.
* **ContentType**: Specify the type of content for the files related to the specified extensions.\
  E.g.: "Code", "Project", "Markup", "Data", etc.
* **SourceExtensions**: The extensions of the files that will be associated to this configuration.\
  E,g,: "cs", "java", "lsp", "vb", etc.&#x20;
* **BinaryExtensions**: Extensions that will be associated to this technology, but will be assumed as binary, so they wont be opened to count lines. Only bytes will be counted.
* **CaseSensitive**: Whether the keywords are case sensitive or not.
* **SeparatorChars**: List of chars to be interpreted as separators.
* **SymbolChars**: List of chars to be interpreted as symbols.
* **WordChars**: List of chars to be interpreted as identifiers or keywords.
* **IgnoreBlockDescriptors**: List of blocks to be ignored in the code (typically block-comments or comments)
  * **Start**: token that starts the block. E.g.: "/\*" for block comments or "\\"" for strings.
  * **End**: token that ends the block. E.g.: "\*/" for block comments or "\\"" for strings.
  * **Ignore**: sequences of chars to be skipped, not to be confused as part of the "End" element. \
    E.g.: inside strings a \\" must not be interpreted as an end of string, unless it is preceded by an odd number of \\. (see sample file above)
  * **Kind**: "Comment" (comment block) or "Content" (strings)
* **LineComment**: the char sequence that starts a line comment.&#x20;
* **Keywords**: the list of all the keywords that must be counted for that language/technology. A keyword can combine word, symbol and separator characters. If a keyword contains one or more separators, the ByteInsight will support any amount of separators at the corresponding locations.

### Default char classifications

If a char is not specified in "SeparatorChars", "SymbolChars" or "WordChars", they will be classified by using the .Net `char.IsSeparator` for separators and `char.IsLetterOrDigit` for words. If none of them return true the character will be assumed to be a symbol.

## Create your own configuration files

You can create your own configuration files to support new technologies or override the settings for existing ones.\
You can do that by following these steps:

* Create a .cfg file for each Technology/Configuration you want to support.\
  (If a technology has files with different formats, you can create different .cfg files with the same technology name.)
* Fill up the settings as previously explained.
* Copy the .cfg files in the following path:
  * %appdata%\Roaming\Mobilize.Net\GenericCounter\
    (you can type %appdata% in the windows explorer, it will take you to the "appdata" folder)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gapvelocity.ai/byteinsight-documentation/guides/how-to-customize-byteinsight.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
