Skip to content

feat(scripts): Add AIDLC Code Reviewer to scripts/#2

Open
ayushtr-aws wants to merge 1 commit into
mainfrom
bgagent/01KRMA0YBBZC67W7Z6JWT1NT19/add-aidlc-code-reviewer-to-scriptsaidlc
Open

feat(scripts): Add AIDLC Code Reviewer to scripts/#2
ayushtr-aws wants to merge 1 commit into
mainfrom
bgagent/01KRMA0YBBZC67W7Z6JWT1NT19/add-aidlc-code-reviewer-to-scriptsaidlc

Conversation

@ayushtr-aws

Copy link
Copy Markdown
Owner

Summary

  • Adds scripts/aidlc-codereview/ — a pip-installable Python package providing automated, language-agnostic code quality analysis with AI-powered review via Amazon Bedrock
  • Source cloned from ayushtr-aws/aidlc-codereview, files copied from AIDLC-CodeReviewer/ directory
  • Follows the scripts/aidlc-traceability/ package structure convention

Package Structure

scripts/aidlc-codereview/
├── src/code_reviewer/
│   ├── __init__.py
│   ├── runner.py                  # main CLI pipeline
│   ├── review-config.yaml         # tool list config
│   ├── agent-config.yaml          # Bedrock model + AWS config
│   ├── agent/                     # AI agents (critical findings, structure critique, business logic, wrapper generator)
│   ├── common/                    # shared utilities (CLI, config, models, report, language detector)
│   ├── tools/                     # tool registry (dynamic wrapper loading)
│   └── prompts/                   # LLM prompt templates (4 markdown files)
├── docs/SETUP.md
├── pyproject.toml
├── README.md
├── LICENSE (MIT-0)
└── CHANGELOG.md (v0.2.0)

Key Decisions

  • Package namespace: code_reviewer — all cross-module imports updated to from code_reviewer.X import Y
  • Config YAML placement: src/code_reviewer/review-config.yaml and agent-config.yaml remain siblings to the package root so Path(__file__).parent.parent resolution in common/config.py and agent/config.py works correctly after pip install -e .
  • Entry point: code_reviewer.common.cli:mainaidlc-code-reviewer CLI
  • Excluded files (per task spec): setup.py, bandit.py/pyflakes.py/semgrep.py/google_java_format.py tool wrappers, reports/, docs/*.drawio, docs/*.png
  • Pre-existing lint fixes: Removed duplicate generate_summary_html function (dead code in original), fixed unused imports and bare f-strings identified by ruff

Build and Test Results

$ pip install -e scripts/aidlc-codereview
Successfully installed aidlc-code-reviewer-0.2.0

$ aidlc-code-reviewer --preflight
=== Pre-flight Check: Agent Setup ===

[1/4] Checking agent Python packages...  OK
[2/4] Checking agent configuration...    Model: us.anthropic.claude-sonnet-4-6
[3/4] Checking AWS credentials...        ✓ identity confirmed
      Checking Amazon Bedrock access...  ✓ model accessible (stop: end_turn)
[4/4] Checking configured tools...       bandit (CLI present), flake8/pyflakes (not installed — will auto-generate)

No critical errors. Agent can run.

$ ruff check src/
All checks passed!

Note: mise run build and mise run lint are not defined at the repo root level — no build system for the monorepo itself. Package-level ruff passes cleanly.

Agent notes

What went well:

  • Import rewriting with a single Python regex pass worked reliably for all 16+ Python files
  • The Path(__file__).parent.parent pattern in config.py and agent/config.py resolves correctly with the src/code_reviewer/ layout — no path hacks needed
  • Dynamic wrapper loading in tools/registry.py adds code_reviewer/ to sys.path, so generated wrappers can still use from common.models import ... as-is

What was difficult:

  • The source repo's common/report.py had a duplicate generate_summary_html function (and duplicate CSS string) — pre-existing bug in the source. Removed the first (incomplete) definition.
  • The venv Python (/app/.venv) and user-installed pip (~/.local) were different Python environments. The aidlc-code-reviewer binary was placed in ~/.local/bin and uses the user-local Python; PYTHONPATH workaround was needed for direct python3 -c import testing.

Patterns discovered:

  • Scripts follow src/<package_name>/ layout with hatchling (traceability) or setuptools (this package)
  • Conventional commits are expected; docs/ADMINISTRATIVE_GUIDE.md describes the release process

Suggestions for future tasks:

  • Add a tests/ directory with at least import-smoke tests
  • Consider adding this package to mise.toml tasks if the repo gains a build system
  • The tools/registry.py dynamic loading could be enhanced to use code_reviewer.tools.{name} namespace for generated wrappers to avoid potential sys.path pollution

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

Adds scripts/aidlc-codereview/ — a pip-installable Python package that
provides static analysis + AI-powered code review via Amazon Bedrock.

Source: cloned from ayushtr-aws/aidlc-codereview (AIDLC-CodeReviewer/)
Structure follows scripts/aidlc-traceability/ conventions.

Key changes from upstream:
- Package namespace: code_reviewer (all imports prefixed with code_reviewer.)
- Entry point: code_reviewer.common.cli:main → aidlc-code-reviewer CLI
- Config YAMLs kept in src/code_reviewer/ (Path(__file__).parent.parent resolves correctly)
- Excluded: setup.py, bandit.py/pyflakes.py/semgrep.py/google_java_format.py tool wrappers, reports/, docs/*.drawio, docs/*.png
- Fixed pre-existing ruff issues: duplicate generate_summary_html, unused imports, bare f-strings

Testing:
- pip install -e . succeeds
- aidlc-code-reviewer --preflight passes (AWS credentials + Bedrock access validated)
- ruff check src/ → All checks passed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Task-Id: 01KRMA0YBBZC67W7Z6JWT1NT19
Prompt-Version: 1c9c10e027a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant