usecase
code_context_agent.usecase ¶
The codebase-analysis :class:~strands_teams.UseCase implementation.
CodebaseAnalysisUseCase is the single object that plugs the code-context domain into the generic strands_teams framework. It supplies:
- the analysis tool roster (discovery, git, BM25, shell tools + the domain
read_heuristic_summarytool + the GitNexus / context7 MCP providers), - the coordinator prompt template + its
partials//steering/directory, - the :class:
~code_context_agent.models.output.AnalysisResultstructured-output model, - the five-phase :class:
~strands_teams.PhaseSpec(tool→phase map + names), - the reasoning-checkpoint prompt map and fail-fast exempt set,
- the
CODE_CONTEXT_-prefixed :class:~code_context_agent.config.Settingswith the.code-contextoutput dir and theNarrativeRubric, - the kickoff-prompt builder and artifact-structure spec, and
- a
pre_rundeterministic auto-index step.
The reasoning-prompt map and exempt set are ported verbatim from the pre-split agent/hooks.py (which Wave D deletes) so this module owns them outright.
CodebaseAnalysisUseCase ¶
Bases: UseCase
The codebase-analysis use case for the strands_teams framework.
Constructs with sensible defaults for the current repository. Passing an explicit output_root overrides where run artifacts land; otherwise the layout root is left unset until :meth:bind is called with the target root.
Initialize the use case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_root | Path | None | Directory root for run artifacts. Defaults to | None |
settings | Settings | None | Pre-built settings. Defaults to a fresh :class: | None |
Source code in packages/code-context-agent/src/code_context_agent/usecase.py
bind ¶
Rebind the layout to a concrete output root (e.g. <repo>/.code-context).
domain_tools ¶
Return the domain analysis tool roster for the coordinator/team agents.
Includes discovery, git, BM25, and shell tools, the domain read_heuristic_summary tool, and the GitNexus / context7 MCP providers (each omitted if unavailable, AC-6-6). The strands_tools graph tool is intentionally dropped (AC-9-7).
Tool modules are imported here (factory pattern) to keep import cost low and avoid circular imports.
Source code in packages/code-context-agent/src/code_context_agent/usecase.py
prompt_template ¶
template_dir ¶
Return the directory containing this use case's prompt templates.
planning_context ¶
Load the planning context injected into the coordinator prompt.
Reads the planning sentinel (heuristic_summary.json) and overlays it on an explicit default skeleton so that every heuristic.* path the coordinator template dereferences resolves under StrictUndefined — this replaces the pre-split _DictProxy safe-0 fallback (AC-6-1).
Returns:
| Type | Description |
|---|---|
dict[str, Any] |
|
dict[str, Any] | merged heuristic namespace (with every template-dereferenced key |
dict[str, Any] | present) plus the run's repo/output paths. |
dict[str, Any] | the coordinator template with this whole dict bound to the name |
dict[str, Any] |
|
dict[str, Any] |
|
Source code in packages/code-context-agent/src/code_context_agent/usecase.py
kickoff_prompt ¶
Build the initial task prompt handed to the coordinator.
Ported from agent/runner.py:_build_analysis_prompt (L55-100). The coordinator's system prompt provides the main workflow; this prompt adds optional focus and user-supplied issue context.
Source code in packages/code-context-agent/src/code_context_agent/usecase.py
artifact_structure_spec ¶
Return prompt text describing the sections each artifact must contain.
pre_run ¶
Auto-index the repository if the planning sentinel is missing.
Ported from agent/runner.py:314-324. Produces heuristic_summary.json (the planning sentinel) via the deterministic indexer before the coordinator runs (AC-6-2, AC-6-4). No-op if the sentinel already exists.