Liking cljdoc? Tell your friends :D

wagoe.ai.core.context

Pure context-extraction functions for AI features.

FC/IS rule: file I/O happens in the caller (shell layer). These functions receive already-read content as strings/maps and transform it into context strings for prompt building.

Pure context-extraction functions for AI features.

FC/IS rule: file I/O happens in the caller (shell layer).
These functions receive already-read content as strings/maps
and transform it into context strings for prompt building.
raw docstring

derive-test-nsclj

(derive-test-ns source-path)

Derive the test namespace string from a source file path.

Example: 'libs/user/src/wagoe/user/core/validation.clj' => 'wagoe.user.core.validation-test'

Args: source-path - file path string

Returns: Test namespace string.

Derive the test namespace string from a source file path.

Example:
  'libs/user/src/wagoe/user/core/validation.clj'
  => 'wagoe.user.core.validation-test'

Args:
  source-path - file path string

Returns:
  Test namespace string.
sourceraw docstring

derive-test-pathclj

(derive-test-path source-path)

Derive the file path a generated test namespace belongs at.

Example: 'libs/user/src/wagoe/user/core/validation.clj' => 'libs/user/test/wagoe/user/core/validation_test.clj'

Both monorepo layouts (libs/<lib>/src/...) and generated-project layouts (src/...) work: the first src path segment becomes test. Matching a segment rather than a substring keeps a directory such as srcgen/ or a namespace containing src from being rewritten.

Args: source-path - file path string

Returns: Test file path string, or nil when source-path has no src segment — there is no convention to apply, and guessing one would put the file somewhere Kaocha does not look.

Derive the file path a generated test namespace belongs at.

Example:
  'libs/user/src/wagoe/user/core/validation.clj'
  => 'libs/user/test/wagoe/user/core/validation_test.clj'

Both monorepo layouts (`libs/<lib>/src/...`) and generated-project layouts
(`src/...`) work: the first `src` path *segment* becomes `test`. Matching a
segment rather than a substring keeps a directory such as `srcgen/` or a
namespace containing `src` from being rewritten.

Args:
  source-path - file path string

Returns:
  Test file path string, or nil when `source-path` has no src segment —
  there is no convention to apply, and guessing one would put the file
  somewhere Kaocha does not look.
sourceraw docstring

determine-test-typeclj

(determine-test-type file-path)

Determine the Kaocha test type for a source file path.

Args: file-path - string like 'libs/user/src/wagoe/user/core/validation.clj'

Returns: :unit, :integration, or :contract keyword.

Determine the Kaocha test type for a source file path.

Args:
  file-path - string like 'libs/user/src/wagoe/user/core/validation.clj'

Returns:
  :unit, :integration, or :contract keyword.
sourceraw docstring

extract-file-referencesclj

(extract-file-references stacktrace)

Extract file:line references from a stack trace string.

Finds patterns like (file.clj:42) or file.clj:42 in the trace.

Args: stacktrace - stack trace string

Returns: Sorted distinct seq of 'filename:line' strings.

Extract file:line references from a stack trace string.

Finds patterns like (file.clj:42) or file.clj:42 in the trace.

Args:
  stacktrace - stack trace string

Returns:
  Sorted distinct seq of 'filename:line' strings.
sourceraw docstring

extract-module-namesclj

(extract-module-names lib-dirs)

Extract existing module names from a list of directory paths.

Args: lib-dirs - seq of path strings like ["libs/user" "libs/core" ...]

Returns: Sorted seq of module name strings (basename of each path).

Extract existing module names from a list of directory paths.

Args:
  lib-dirs - seq of path strings like ["libs/user" "libs/core" ...]

Returns:
  Sorted seq of module name strings (basename of each path).
sourceraw docstring

extract-public-function-namesclj

(extract-public-function-names source)

Extract public defn names from a Clojure source string.

Args: source - Clojure source code string

Returns: Seq of function name strings.

Extract public defn names from a Clojure source string.

Args:
  source - Clojure source code string

Returns:
  Seq of function name strings.
sourceraw docstring

extract-schema-contextclj

(extract-schema-context schema-files)

Build a schema context string from a map of schema file contents.

Args: schema-files - map of {relative-path source-str} for schema.clj files

Returns: A human-readable summary string of table names and fields found.

Build a schema context string from a map of schema file contents.

Args:
  schema-files - map of {relative-path source-str} for schema.clj files

Returns:
  A human-readable summary string of table names and fields found.
sourceraw docstring

filter-clj-sourcesclj

(filter-clj-sources all-files)

From a map of {path content}, keep only .clj source files under src/.

Args: all-files - map of {path content-str}

Returns: Filtered map.

From a map of {path content}, keep only .clj source files under src/.

Args:
  all-files - map of {path content-str}

Returns:
  Filtered map.
sourceraw docstring

summarise-stacktraceclj

(summarise-stacktrace stacktrace)
(summarise-stacktrace stacktrace n)

Return the first N lines of a stack trace (to fit context window).

Args: stacktrace - full stack trace string n - max number of lines (default 60)

Returns: Truncated string.

Return the first N lines of a stack trace (to fit context window).

Args:
  stacktrace - full stack trace string
  n          - max number of lines (default 60)

Returns:
  Truncated string.
sourceraw docstring

truncate-sourceclj

(truncate-source source)
(truncate-source source max-lines)

Truncate a source file string to max-lines lines to fit context.

Args: source - source code string max-lines - maximum number of lines to keep (default 150)

Returns: Possibly truncated string with a note if truncated.

Truncate a source file string to max-lines lines to fit context.

Args:
  source    - source code string
  max-lines - maximum number of lines to keep (default 150)

Returns:
  Possibly truncated string with a note if truncated.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close