> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codealive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Grep search

> Searches indexed code for exact literal text or a regular expression (set `regex` to `true`). First choice when you already know an exact symbol name, string literal, error message, route, or configuration key, and for exhaustive "find every usage" sweeps. It complements `semantic_search`: embeddings underrepresent rare short tokens such as acronyms (`JWT`, `OIDC`), so run `grep_search` on the exact token alongside a semantic query rather than instead of it.



## OpenAPI

````yaml /openapi-tool-api-v3.json post /api/tools/grep_search
openapi: 3.1.1
info:
  title: CodeAlive Tool API
  description: >-
    Tool-only OpenAPI 3.1 contract for MCP and agent integrations. Every
    operation is read-only and returns a Tool API envelope.
  contact:
    name: CodeAlive Team
    url: https://codealive.ai
    email: support@codealive.ai
  license:
    name: Terms of Service
    url: https://app.codealive.ai/terms
  version: 3.0.0
servers:
  - url: https://app.codealive.ai
security:
  - ApiKeyScheme: []
tags:
  - name: ToolApi
    description: CodeAlive Tool API v3
paths:
  /api/tools/grep_search:
    post:
      tags:
        - ToolApi
      summary: Grep search
      description: >-
        Searches indexed code for exact literal text or a regular expression
        (set `regex` to `true`). First choice when you already know an exact
        symbol name, string literal, error message, route, or configuration key,
        and for exhaustive "find every usage" sweeps. It complements
        `semantic_search`: embeddings underrepresent rare short tokens such as
        acronyms (`JWT`, `OIDC`), so run `grep_search` on the exact token
        alongside a semantic query rather than instead of it.
      operationId: ToolApiGrepSearch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GrepSearchToolRequest'
            example:
              query: TaskExecutor
              data_sources:
                - CodeAlive-AI/agent-framework
          text/json:
            schema:
              $ref: '#/components/schemas/GrepSearchToolRequest'
          application/*+json:
            schema:
              $ref: '#/components/schemas/GrepSearchToolRequest'
      responses:
        '200':
          description: >-
            Success envelope. obj.results[] adds grep specifics: matchCount and
            matches[] with lineNumber, column range, and lineText; rendered is a
            <grep_search_results> XML block. Repairable failures (missing or
            invalid arguments, ambiguous or unknown data sources) also return
            HTTP 200 with obj.error = { code, message, retry, try } and a
            rendered <tool_error> block; repair the arguments and retry.
          content:
            application/json:
              schema:
                oneOf:
                  - required:
                      - obj
                      - rendered
                    type: object
                    properties:
                      obj:
                        $ref: '#/components/schemas/GrepSearchResponse'
                      rendered:
                        type: string
                        description: Agent-facing result text.
                    additionalProperties: false
                    description: >-
                      Default success projection returned when output_format is
                      omitted.
                  - required:
                      - obj
                    type: object
                    properties:
                      obj:
                        $ref: '#/components/schemas/GrepSearchResponse'
                    additionalProperties: false
                    description: >-
                      Structured success projection returned when output_format
                      is json.
                  - required:
                      - rendered
                    type: object
                    properties:
                      rendered:
                        type: string
                        description: Agent-facing result text.
                    additionalProperties: false
                    description: >-
                      Agent-facing success projection returned when
                      output_format is agentic.
                  - required:
                      - obj
                      - rendered
                    type: object
                    properties:
                      obj:
                        $ref: '#/components/schemas/ToolApiRepairableResult'
                      rendered:
                        type: string
                        description: Agent-facing result text.
                    additionalProperties: false
                    description: >-
                      Repairable failure. Always includes both projections and
                      uses HTTP 200.
              examples:
                default:
                  summary: Default success response
                  description: >-
                    Returned when output_format is omitted; includes both
                    projections.
                  value:
                    obj:
                      results:
                        - kind: file
                          dataSource:
                            type: Repository
                            id: 665f1c2ab3e77d0c9a1b4d21
                            name: agent-framework
                          identifier: CodeAlive-AI/agent-framework::src/executor.py
                          location:
                            path: src/executor.py
                            range:
                              start:
                                line: 42
                                character: 6
                              end:
                                line: 42
                                character: 18
                          startLine: 42
                          endLine: 88
                          score: 1
                          contentByteSize: 2048
                          matchCount: 2
                          summary: Executes queued tasks with retry and telemetry.
                          matches:
                            - lineNumber: 42
                              startColumn: 7
                              endColumn: 18
                              lineText: 'class TaskExecutor:'
                              contextLines:
                                - lineNumber: 41
                                  lineText: '@instrumented'
                                - lineNumber: 42
                                  lineText: 'class TaskExecutor:'
                                - lineNumber: 43
                                  lineText: '    def run(self, task):'
                    rendered: >-
                      <grep_search_results count="1">
                        <result identifier="CodeAlive-AI/agent-framework::src/executor.py" path="src/executor.py" source="agent-framework" match_count="2" />
                      </grep_search_results>

                      Fetch relevant identifiers with fetch_artifacts or read
                      local files before drawing conclusions.
                json_only:
                  summary: JSON success response
                  description: Returned when output_format is json.
                  value:
                    obj:
                      results:
                        - kind: file
                          dataSource:
                            type: Repository
                            id: 665f1c2ab3e77d0c9a1b4d21
                            name: agent-framework
                          identifier: CodeAlive-AI/agent-framework::src/executor.py
                          location:
                            path: src/executor.py
                            range:
                              start:
                                line: 42
                                character: 6
                              end:
                                line: 42
                                character: 18
                          startLine: 42
                          endLine: 88
                          score: 1
                          contentByteSize: 2048
                          matchCount: 2
                          summary: Executes queued tasks with retry and telemetry.
                          matches:
                            - lineNumber: 42
                              startColumn: 7
                              endColumn: 18
                              lineText: 'class TaskExecutor:'
                              contextLines:
                                - lineNumber: 41
                                  lineText: '@instrumented'
                                - lineNumber: 42
                                  lineText: 'class TaskExecutor:'
                                - lineNumber: 43
                                  lineText: '    def run(self, task):'
                agentic_only:
                  summary: Agent-facing success response
                  description: Returned when output_format is agentic.
                  value:
                    rendered: >-
                      <grep_search_results count="1">
                        <result identifier="CodeAlive-AI/agent-framework::src/executor.py" path="src/executor.py" source="agent-framework" match_count="2" />
                      </grep_search_results>

                      Fetch relevant identifiers with fetch_artifacts or read
                      local files before drawing conclusions.
                repairable_error:
                  summary: Repairable tool error
                  description: >-
                    Returned with HTTP 200 when arguments can be corrected and
                    retried.
                  value:
                    obj:
                      error:
                        code: unknown_argument
                        message: >-
                          Unknown JSON argument(s) are not accepted in Tool API
                          v3: search_mode.
                        retry: >-
                          yes - repair the tool arguments and call the tool
                          again
                        try: >-
                          Use only the canonical arguments documented for this
                          tool.
                    rendered: |
                      <tool_error>
                        <code>unknown_argument</code>
                        <message>Unknown JSON argument(s) are not accepted in Tool API v3: search_mode.</message>
                        <retry>yes - repair the tool arguments and call the tool again</retry>
                        <try>Use only the canonical arguments documented for this tool.</try>
                      </tool_error>
            text/json:
              schema:
                $ref: '#/components/schemas/ToolApiEnvelope'
        '400':
          description: >-
            Bad request, including malformed JSON, unknown output_format, or
            invalid transport-level input.
        '401':
          description: Authentication failed or API key is missing.
        '403':
          description: >-
            The caller is not authorized for the requested data source or plan
            feature.
        '429':
          description: Rate limit, quota, or plan limit exceeded.
        '500':
          description: Unexpected server failure.
components:
  schemas:
    GrepSearchToolRequest:
      required:
        - query
      type: object
      properties:
        output_format:
          enum:
            - json
            - agentic
          type:
            - 'null'
            - string
          description: >-
            Optional success projection. Omit to return both obj and rendered;
            use json for obj only; use agentic for rendered text only.
            Repairable errors always return both obj.error and rendered.
        query:
          type:
            - 'null'
            - string
          description: Literal string or regex pattern to search for.
        data_sources:
          type:
            - 'null'
            - array
          items:
            type: string
          description: >-
            Repository or workspace names returned by get_data_sources. Omit
            only when the API key has a single unambiguous scope.
        paths:
          type:
            - 'null'
            - array
          items:
            type: string
          description: Optional repository-relative path prefixes to include.
        extensions:
          type:
            - 'null'
            - array
          items:
            type: string
          description: Optional file extensions to include, for example cs, ts, or py.
        max_results:
          type:
            - 'null'
            - integer
          description: Optional maximum number of search results.
          format: int32
        exclude_markdown:
          type:
            - 'null'
            - boolean
          description: Exclude Markdown files from search results. Default is false.
        regex:
          type:
            - 'null'
            - boolean
          description: Set true to treat query as a regular expression. Default is false.
      additionalProperties: false
    GrepSearchResponse:
      type: object
      properties:
        results:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/GrepSearchResultDto'
          description: Artifacts containing literal or regular-expression matches.
        pathFilter:
          $ref: '#/components/schemas/PathFilterDiagnostic'
          description: Path-filter interpretation and rejection diagnostics.
        warnings:
          type: array
          items:
            $ref: '#/components/schemas/ToolApiWarning'
          description: >-
            Compatibility warnings, such as accepted deprecated argument
            aliases.
      additionalProperties: false
    ToolApiRepairableResult:
      required:
        - error
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ToolApiRepairableError'
          description: Structured error details used to repair the request and retry.
        warnings:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/ToolApiWarning'
          description: Compatibility warnings emitted before the request failed.
      additionalProperties: false
      description: >-
        Repairable failure returned with HTTP 200 so an agent can correct the
        request and retry.
    ToolApiEnvelope:
      type: object
      properties:
        obj:
          description: >-
            Arbitrary JSON result for the tool. Present for omitted/json success
            projections and every repairable error.
        rendered:
          type:
            - 'null'
            - string
          description: >-
            Agent-facing result text. Present for omitted/agentic success
            projections and every repairable error.
      additionalProperties: false
    GrepSearchResultDto:
      type: object
      properties:
        kind:
          type:
            - 'null'
            - string
          description: Matched artifact kind.
        dataSource:
          $ref: '#/components/schemas/DataSourceDto'
          description: Repository or workspace containing the match.
        identifier:
          type:
            - 'null'
            - string
          description: Stable identifier accepted by fetch and relationship tools.
        location:
          $ref: '#/components/schemas/LocationDto'
          description: Primary file location; line is 1-based and character is 0-based.
        startLine:
          type:
            - 'null'
            - integer
          description: 1-based artifact start line when indexed.
          format: int32
        endLine:
          type:
            - 'null'
            - integer
          description: 1-based artifact end line when indexed.
          format: int32
        score:
          type: number
          description: Search relevance score.
          format: double
        contentByteSize:
          type:
            - 'null'
            - integer
          description: Artifact content size in bytes when known.
          format: int64
        matchCount:
          type: integer
          description: Total matches found in this artifact.
          format: int32
        matches:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/GrepSearchMatchDto'
          description: Bounded preview of individual matches.
        matchedByName:
          type:
            - 'null'
            - boolean
          description: True when only the file name or path matched.
        summary:
          type:
            - 'null'
            - string
          description: AI-generated short artifact summary.
      additionalProperties: false
    PathFilterDiagnostic:
      type: object
      properties:
        interpreted:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/PatternInterpretation'
          description: Accepted path patterns and their interpretation.
        rejected:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/PathFilterRejection'
          description: Rejected path patterns with repair recommendations.
        matchAll:
          type: boolean
          description: Whether the path scope matches every file.
        scopeHasMatches:
          type:
            - 'null'
            - boolean
          description: Whether any indexed files match the path scope.
        status:
          $ref: '#/components/schemas/PathFilterStatus'
          description: Path-filter evaluation status.
      additionalProperties: false
    ToolApiWarning:
      type: object
      properties:
        code:
          type:
            - 'null'
            - string
          description: Stable machine-readable warning code.
        message:
          type:
            - 'null'
            - string
          description: Human-readable compatibility warning.
        alias:
          type:
            - 'null'
            - string
          description: Deprecated argument alias that was accepted.
        canonical:
          type:
            - 'null'
            - string
          description: Canonical argument name to use instead of the alias.
      additionalProperties: false
    ToolApiRepairableError:
      type: object
      properties:
        code:
          type:
            - 'null'
            - string
          description: Stable machine-readable error code.
        message:
          type:
            - 'null'
            - string
          description: Human-readable explanation of the invalid request.
        retry:
          type:
            - 'null'
            - string
          description: Whether the caller should correct the request and retry.
        try:
          type:
            - 'null'
            - string
          description: Concrete guidance for repairing the next request.
      additionalProperties: false
    DataSourceDto:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
          description: Repository or Workspace.
        id:
          type:
            - 'null'
            - string
          description: Stable data-source identifier.
        name:
          type:
            - 'null'
            - string
          description: Data-source display name.
      additionalProperties: false
    LocationDto:
      type: object
      properties:
        path:
          type:
            - 'null'
            - string
          description: Repository-relative file path.
        range:
          $ref: '#/components/schemas/RangeDto'
          description: Source range within the file.
      additionalProperties: false
    GrepSearchMatchDto:
      type: object
      properties:
        lineNumber:
          type: integer
          description: 1-based line number.
          format: int32
        startColumn:
          type: integer
          description: 1-based inclusive start column.
          format: int32
        endColumn:
          type: integer
          description: 1-based inclusive end column.
          format: int32
        lineText:
          type:
            - 'null'
            - string
          description: Source line containing the match.
        remark:
          type:
            - 'null'
            - string
          description: Preview limitation or truncation note.
        contextLines:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/GrepSearchPreviewLineDto'
          description: Previous, matching, and next preview lines when available.
      additionalProperties: false
    PatternInterpretation:
      type: object
      properties:
        input:
          type:
            - 'null'
            - string
          description: Original path-filter pattern.
        class:
          $ref: '#/components/schemas/PathPatternClass'
          description: Detected pattern class, such as exact path, prefix, or glob.
        tier:
          $ref: '#/components/schemas/PathPatternTier'
          description: Matching tier selected for the pattern.
        isNegation:
          type: boolean
          description: Whether the pattern excludes matching paths.
      additionalProperties: false
    PathFilterRejection:
      type: object
      properties:
        input:
          type:
            - 'null'
            - string
          description: Original rejected path-filter pattern.
        reason:
          $ref: '#/components/schemas/PathSpecRejectionReason'
          description: Why the pattern could not be applied.
        recommendation:
          type:
            - 'null'
            - string
          description: Suggested replacement or correction.
      additionalProperties: false
    PathFilterStatus:
      enum:
        - NoPaths
        - ScopeMatchedZeroFiles
        - ScopeMatchedNoContent
        - AllPathsRejected
      type: string
    RangeDto:
      type: object
      properties:
        start:
          $ref: '#/components/schemas/PositionDto'
          description: Range start position.
        end:
          $ref: '#/components/schemas/PositionDto'
          description: Range end position.
      additionalProperties: false
    GrepSearchPreviewLineDto:
      type: object
      properties:
        lineNumber:
          type: integer
          description: 1-based source line number.
          format: int32
        lineText:
          type:
            - 'null'
            - string
          description: Capped source-line preview.
      additionalProperties: false
    PathPatternClass:
      enum:
        - PlainPath
        - BareToken
        - BasenameOnly
        - SimpleGlob
        - PosixGlob
        - Regex
        - Substring
      type: string
    PathPatternTier:
      enum:
        - PlainPath
        - Wildcard
        - Regex
        - PostFilter
      type: string
    PathSpecRejectionReason:
      enum:
        - EmptyAfterTrim
        - NegationOnlyNoBody
        - PatternTooLong
        - PatternExpansionTooLarge
        - PcreFeatureUnsupported
        - RegexSyntaxUnsupported
        - RegexNoLiteral
        - NoSafeLiteral
        - EmbeddedAnchor
        - TotalFanoutExceeded
      type: string
    PositionDto:
      type: object
      properties:
        line:
          type: integer
          description: 1-based source line.
          format: int32
        character:
          type: integer
          description: 0-based character offset.
          format: int32
      additionalProperties: false
  securitySchemes:
    ApiKeyScheme:
      type: http
      description: >-
        API Key authentication using Bearer token. Example: "Authorization:
        Bearer {apiKey}"
      scheme: bearer
      bearerFormat: API Key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.