logicfalcon 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aegis/__init__.py +36 -0
- aegis/cli.py +134 -0
- logicfalcon/__init__.py +70 -0
- logicfalcon/cli.py +134 -0
- logicfalcon/sdk.py +166 -0
- logicfalcon-0.1.1.dist-info/METADATA +244 -0
- logicfalcon-0.1.1.dist-info/RECORD +100 -0
- logicfalcon-0.1.1.dist-info/WHEEL +4 -0
- logicfalcon-0.1.1.dist-info/entry_points.txt +3 -0
- logicfalcon-0.1.1.dist-info/licenses/LICENSE +202 -0
- packages/__init__.py +1 -0
- packages/common/__init__.py +3 -0
- packages/common/storage.py +81 -0
- packages/config/__init__.py +3 -0
- packages/config/settings.py +137 -0
- packages/intelligence/code/__init__.py +44 -0
- packages/intelligence/code/impact_analysis.py +144 -0
- packages/intelligence/code/indexer.py +267 -0
- packages/intelligence/code/parser_base.py +187 -0
- packages/intelligence/code/system_intelligence.py +237 -0
- packages/intelligence/code/ts_parser.py +514 -0
- packages/intelligence/debugging/__init__.py +59 -0
- packages/intelligence/debugging/analyzer.py +210 -0
- packages/intelligence/debugging/collector.py +206 -0
- packages/intelligence/debugging/localizer.py +110 -0
- packages/intelligence/debugging/models.py +222 -0
- packages/intelligence/debugging/normalizer.py +80 -0
- packages/intelligence/debugging/remediation_proposals.py +152 -0
- packages/intelligence/debugging/service.py +197 -0
- packages/intelligence/debugging/stack_parser.py +138 -0
- packages/intelligence/debugging/verification.py +105 -0
- packages/intelligence/embeddings/__init__.py +15 -0
- packages/intelligence/embeddings/provider.py +53 -0
- packages/intelligence/evidence/__init__.py +46 -0
- packages/intelligence/evidence/engine.py +208 -0
- packages/intelligence/evidence/graph.py +242 -0
- packages/intelligence/evidence/graph_models.py +211 -0
- packages/intelligence/evidence/models.py +61 -0
- packages/intelligence/evidence/providers.py +441 -0
- packages/intelligence/knowledge/__init__.py +17 -0
- packages/intelligence/knowledge/store.py +232 -0
- packages/intelligence/reasoning/context.py +131 -0
- packages/intelligence/reasoning/hypotheses.py +215 -0
- packages/intelligence/reasoning/prompts/investigation_system.txt +16 -0
- packages/intelligence/reasoning/prompts/investigation_user.txt +40 -0
- packages/intelligence/reasoning/provider.py +212 -0
- packages/intelligence/reasoning/reliability.py +217 -0
- packages/intelligence/reasoning/router.py +227 -0
- packages/intelligence/reasoning/validator.py +100 -0
- packages/intelligence/system/__init__.py +19 -0
- packages/intelligence/system/context.py +65 -0
- packages/intelligence/system/registry.py +145 -0
- packages/llm/__init__.py +3 -0
- packages/llm/boundary.py +25 -0
- packages/logging/__init__.py +3 -0
- packages/logging/logger.py +102 -0
- packages/reliability/__init__.py +23 -0
- packages/reliability/adapter.py +304 -0
- packages/reliability/domain.py +99 -0
- packages/review/__init__.py +45 -0
- packages/review/adapters/__init__.py +13 -0
- packages/review/adapters/ast_security.py +417 -0
- packages/review/adapters/base.py +34 -0
- packages/review/adapters/ruff_adapter.py +171 -0
- packages/review/adapters/runner.py +221 -0
- packages/review/adapters/typescript_stub.py +35 -0
- packages/review/ai/__init__.py +16 -0
- packages/review/ai/context_builder.py +158 -0
- packages/review/ai/prompts.py +61 -0
- packages/review/ai/reviewer.py +250 -0
- packages/review/ai/schemas.py +31 -0
- packages/review/analyzer/__init__.py +6 -0
- packages/review/analyzer/dependency_graph.py +144 -0
- packages/review/analyzer/symbol_mapper.py +90 -0
- packages/review/cli.py +399 -0
- packages/review/domain/__init__.py +45 -0
- packages/review/domain/models.py +217 -0
- packages/review/engine.py +485 -0
- packages/review/fix_engine.py +335 -0
- packages/review/git/__init__.py +5 -0
- packages/review/git/diff_parser.py +251 -0
- packages/review/github/__init__.py +15 -0
- packages/review/github/client.py +98 -0
- packages/review/github/publisher.py +137 -0
- packages/review/github/webhook.py +91 -0
- packages/review/gitlab/__init__.py +15 -0
- packages/review/gitlab/client.py +105 -0
- packages/review/gitlab/publisher.py +160 -0
- packages/review/security/__init__.py +1 -0
- packages/review/security/path_validation.py +46 -0
- packages/review/validator.py +158 -0
- packages/security/__init__.py +8 -0
- packages/security/llm_firewall/__init__.py +21 -0
- packages/security/llm_firewall/adapter.py +355 -0
- packages/security/policy.py +225 -0
- packages/security/rbac.py +130 -0
- packages/security/tools.py +194 -0
- packages/service_runtime/__init__.py +34 -0
- packages/service_runtime/base.py +88 -0
- packages/service_runtime/metrics.py +230 -0
aegis/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""AEGIS AI — Enterprise-grade AI Engineering, Automated Code Review & Autonomous Debugging Platform.
|
|
2
|
+
|
|
3
|
+
Public API exports for library consumers and integrations.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
from packages.intelligence.debugging.service import AutonomousDebuggingService
|
|
8
|
+
except (ImportError, ModuleNotFoundError):
|
|
9
|
+
class AutonomousDebuggingService: # type: ignore[no-redef]
|
|
10
|
+
"""Autonomous debugging service requires the full AEGIS AI platform backend.
|
|
11
|
+
|
|
12
|
+
This feature is unavailable in the standalone LogicFalcon CLI/SDK distribution.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, *args: object, **kwargs: object) -> None:
|
|
16
|
+
raise RuntimeError(
|
|
17
|
+
"AutonomousDebuggingService requires the optional AEGIS AI platform backend (apps.api). "
|
|
18
|
+
"It is not available in the standalone LogicFalcon CLI/SDK distribution."
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from packages.review.cli import build_parser, run_cli
|
|
22
|
+
from packages.review.domain.models import FindingSeverity, ReviewReport
|
|
23
|
+
from packages.review.engine import LocalReviewEngine, ReviewConfig
|
|
24
|
+
|
|
25
|
+
__version__ = "0.1.1"
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"AutonomousDebuggingService",
|
|
29
|
+
"FindingSeverity",
|
|
30
|
+
"LocalReviewEngine",
|
|
31
|
+
"ReviewConfig",
|
|
32
|
+
"ReviewReport",
|
|
33
|
+
"__version__",
|
|
34
|
+
"build_parser",
|
|
35
|
+
"run_cli",
|
|
36
|
+
]
|
aegis/cli.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Unified Command-Line Interface for AEGIS AI."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
from typing import NoReturn
|
|
7
|
+
|
|
8
|
+
from aegis import __version__
|
|
9
|
+
from packages.intelligence.code.indexer import PythonASTParser
|
|
10
|
+
from packages.intelligence.code.ts_parser import JavaScriptTypeScriptParser
|
|
11
|
+
from packages.review.cli import run_cli as run_review_cli
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def run_doctor() -> int:
|
|
15
|
+
"""Runs a non-destructive environment and capability diagnostic."""
|
|
16
|
+
sys.stdout.write("🛡️ AEGIS AI — System Diagnostic & Capability Doctor\n")
|
|
17
|
+
sys.stdout.write("=" * 60 + "\n")
|
|
18
|
+
|
|
19
|
+
# 1. Python version check
|
|
20
|
+
py_ver = sys.version_info
|
|
21
|
+
py_ok = py_ver >= (3, 12)
|
|
22
|
+
py_status = "PASS" if py_ok else "FAIL"
|
|
23
|
+
sys.stdout.write(f"[{py_status}] Python Version: {py_ver.major}.{py_ver.minor}.{py_ver.micro} (>= 3.12 required)\n")
|
|
24
|
+
|
|
25
|
+
# 2. Git binary check
|
|
26
|
+
git_bin = shutil.which("git")
|
|
27
|
+
git_status = "PASS" if git_bin else "WARN"
|
|
28
|
+
sys.stdout.write(f"[{git_status}] Git Executable: {git_bin or 'Not found in PATH'}\n")
|
|
29
|
+
|
|
30
|
+
# 3. Python AST parser check
|
|
31
|
+
try:
|
|
32
|
+
symbols, _deps = PythonASTParser.parse_source("test.py", "def hello(): pass")
|
|
33
|
+
ast_ok = len(symbols) == 1 and symbols[0].name == "hello"
|
|
34
|
+
ast_status = "PASS" if ast_ok else "FAIL"
|
|
35
|
+
except Exception as e:
|
|
36
|
+
ast_status = f"FAIL ({e})"
|
|
37
|
+
sys.stdout.write(f"[{ast_status}] Python AST Static Analyzer: functional\n")
|
|
38
|
+
|
|
39
|
+
# 4. Multi-language TypeScript parser check
|
|
40
|
+
try:
|
|
41
|
+
ts_res = JavaScriptTypeScriptParser().parse_source("test.ts", "function greet(): string { return 'hi'; }")
|
|
42
|
+
ts_ok = len(ts_res.symbols) == 1 and ts_res.symbols[0].name == "greet"
|
|
43
|
+
ts_status = "PASS" if ts_ok else "FAIL"
|
|
44
|
+
except Exception as e:
|
|
45
|
+
ts_status = f"FAIL ({e})"
|
|
46
|
+
sys.stdout.write(f"[{ts_status}] TypeScript/JavaScript Static Parser: functional\n")
|
|
47
|
+
|
|
48
|
+
# 5. External linter (Ruff) check
|
|
49
|
+
ruff_bin = shutil.which("ruff")
|
|
50
|
+
ruff_status = "PASS" if ruff_bin else "INFO"
|
|
51
|
+
sys.stdout.write(f"[{ruff_status}] External Linter (Ruff): {ruff_bin or 'Optional / Not installed'}\n")
|
|
52
|
+
|
|
53
|
+
# 6. Service infrastructure status (informational)
|
|
54
|
+
sys.stdout.write("[INFO] Backend Services (PostgreSQL / Redis): Optional (not required for CLI review)\n")
|
|
55
|
+
sys.stdout.write("=" * 60 + "\n")
|
|
56
|
+
sys.stdout.write("System diagnostics complete. AEGIS CLI is operational.\n")
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def build_root_parser() -> argparse.ArgumentParser:
|
|
61
|
+
parser = argparse.ArgumentParser(
|
|
62
|
+
prog="aegis",
|
|
63
|
+
description="AEGIS AI — Enterprise-grade AI Engineering, Automated Code Review & Autonomous Debugging CLI",
|
|
64
|
+
)
|
|
65
|
+
parser.add_argument(
|
|
66
|
+
"-v", "--version",
|
|
67
|
+
action="version",
|
|
68
|
+
version=f"aegis-review {__version__}",
|
|
69
|
+
help="Show program's version number and exit.",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
subparsers = parser.add_subparsers(dest="subcommand", help="Available subcommands")
|
|
73
|
+
|
|
74
|
+
# Subcommand: review
|
|
75
|
+
subparsers.add_parser(
|
|
76
|
+
"review",
|
|
77
|
+
help="Run deterministic repository intelligence & automated code review.",
|
|
78
|
+
add_help=False, # Let review parser handle its own flags
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Subcommand: doctor
|
|
82
|
+
subparsers.add_parser(
|
|
83
|
+
"doctor",
|
|
84
|
+
help="Run environment health check, AST parser capabilities, and tool diagnostic.",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return parser
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def run_main(args: list[str] | None = None) -> int:
|
|
91
|
+
argv = sys.argv[1:] if args is None else args
|
|
92
|
+
|
|
93
|
+
# Handle direct review fallback when arguments start with review flags
|
|
94
|
+
if argv and argv[0].startswith("-") and argv[0] not in ("-v", "--version", "-h", "--help"):
|
|
95
|
+
return run_review_cli(argv)
|
|
96
|
+
|
|
97
|
+
if not argv:
|
|
98
|
+
parser = build_root_parser()
|
|
99
|
+
parser.print_help()
|
|
100
|
+
return 0
|
|
101
|
+
|
|
102
|
+
if argv[0] in ("-v", "--version"):
|
|
103
|
+
sys.stdout.write(f"aegis-review {__version__}\n")
|
|
104
|
+
return 0
|
|
105
|
+
|
|
106
|
+
if argv[0] in ("-h", "--help"):
|
|
107
|
+
parser = build_root_parser()
|
|
108
|
+
parser.print_help()
|
|
109
|
+
return 0
|
|
110
|
+
|
|
111
|
+
if argv[0] == "doctor":
|
|
112
|
+
return run_doctor()
|
|
113
|
+
|
|
114
|
+
if argv[0] == "review":
|
|
115
|
+
return run_review_cli(argv[1:])
|
|
116
|
+
|
|
117
|
+
# Fallback to standard argparsing
|
|
118
|
+
parser = build_root_parser()
|
|
119
|
+
parsed = parser.parse_args(argv)
|
|
120
|
+
if parsed.subcommand == "doctor":
|
|
121
|
+
return run_doctor()
|
|
122
|
+
elif parsed.subcommand == "review":
|
|
123
|
+
return run_review_cli(argv[1:])
|
|
124
|
+
|
|
125
|
+
parser.print_help()
|
|
126
|
+
return 0
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def main() -> NoReturn:
|
|
130
|
+
sys.exit(run_main())
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
main()
|
logicfalcon/__init__.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""LogicFalcon — Fast, precise engineering intelligence. Powered by AEGIS AI.
|
|
2
|
+
|
|
3
|
+
LogicFalcon is an AI-powered software engineering intelligence platform for
|
|
4
|
+
evidence-grounded code review, repository analysis, change-impact assessment,
|
|
5
|
+
root-cause analysis, and safe fix proposals. Powered by AEGIS AI.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
from packages.intelligence.debugging.service import AutonomousDebuggingService
|
|
10
|
+
except (ImportError, ModuleNotFoundError):
|
|
11
|
+
class AutonomousDebuggingService: # type: ignore[no-redef]
|
|
12
|
+
"""Autonomous debugging service requires the full AEGIS AI platform backend.
|
|
13
|
+
|
|
14
|
+
This feature is unavailable in the standalone LogicFalcon CLI/SDK distribution.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, *args: object, **kwargs: object) -> None:
|
|
18
|
+
raise RuntimeError(
|
|
19
|
+
"AutonomousDebuggingService requires the optional AEGIS AI platform backend (apps.api). "
|
|
20
|
+
"It is not available in the standalone LogicFalcon CLI/SDK distribution."
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from logicfalcon.sdk import apply_fix, review, review_diff, verify_fix
|
|
24
|
+
from packages.review.cli import build_parser, run_cli
|
|
25
|
+
from packages.review.domain.models import (
|
|
26
|
+
FindingCategory,
|
|
27
|
+
FindingSeverity,
|
|
28
|
+
ProposedFix,
|
|
29
|
+
ReviewFinding,
|
|
30
|
+
ReviewReport,
|
|
31
|
+
ValidationStatus,
|
|
32
|
+
)
|
|
33
|
+
from packages.review.engine import LocalReviewEngine, ReviewConfig
|
|
34
|
+
from packages.review.fix_engine import (
|
|
35
|
+
FixApplicationResult,
|
|
36
|
+
RemediationVerificationResult,
|
|
37
|
+
ReviewFixEngine,
|
|
38
|
+
)
|
|
39
|
+
from packages.review.validator import FindingValidator
|
|
40
|
+
|
|
41
|
+
__version__ = "0.1.1"
|
|
42
|
+
__product__ = "LogicFalcon"
|
|
43
|
+
__tagline__ = "Fast, precise engineering intelligence."
|
|
44
|
+
__platform__ = "AEGIS AI"
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"AutonomousDebuggingService",
|
|
48
|
+
"FindingCategory",
|
|
49
|
+
"FindingSeverity",
|
|
50
|
+
"FindingValidator",
|
|
51
|
+
"FixApplicationResult",
|
|
52
|
+
"LocalReviewEngine",
|
|
53
|
+
"ProposedFix",
|
|
54
|
+
"RemediationVerificationResult",
|
|
55
|
+
"ReviewConfig",
|
|
56
|
+
"ReviewFinding",
|
|
57
|
+
"ReviewFixEngine",
|
|
58
|
+
"ReviewReport",
|
|
59
|
+
"ValidationStatus",
|
|
60
|
+
"__platform__",
|
|
61
|
+
"__product__",
|
|
62
|
+
"__tagline__",
|
|
63
|
+
"__version__",
|
|
64
|
+
"apply_fix",
|
|
65
|
+
"build_parser",
|
|
66
|
+
"review",
|
|
67
|
+
"review_diff",
|
|
68
|
+
"run_cli",
|
|
69
|
+
"verify_fix",
|
|
70
|
+
]
|
logicfalcon/cli.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Unified Command-Line Interface for LogicFalcon (Powered by AEGIS AI)."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
from typing import NoReturn
|
|
7
|
+
|
|
8
|
+
from logicfalcon import __platform__, __product__, __version__
|
|
9
|
+
from packages.intelligence.code.indexer import PythonASTParser
|
|
10
|
+
from packages.intelligence.code.ts_parser import JavaScriptTypeScriptParser
|
|
11
|
+
from packages.review.cli import run_cli as run_review_cli
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def run_doctor() -> int:
|
|
15
|
+
"""Runs a non-destructive environment and capability diagnostic."""
|
|
16
|
+
sys.stdout.write(f"🦅 {__product__} — System Diagnostic & Capability Doctor (Powered by {__platform__})\n")
|
|
17
|
+
sys.stdout.write("=" * 65 + "\n")
|
|
18
|
+
|
|
19
|
+
# 1. Python version check
|
|
20
|
+
py_ver = sys.version_info
|
|
21
|
+
py_ok = py_ver >= (3, 12)
|
|
22
|
+
py_status = "PASS" if py_ok else "FAIL"
|
|
23
|
+
sys.stdout.write(f"[{py_status}] Python Version: {py_ver.major}.{py_ver.minor}.{py_ver.micro} (>= 3.12 required)\n")
|
|
24
|
+
|
|
25
|
+
# 2. Git binary check
|
|
26
|
+
git_bin = shutil.which("git")
|
|
27
|
+
git_status = "PASS" if git_bin else "WARN"
|
|
28
|
+
sys.stdout.write(f"[{git_status}] Git Executable: {git_bin or 'Not found in PATH'}\n")
|
|
29
|
+
|
|
30
|
+
# 3. Python AST parser check
|
|
31
|
+
try:
|
|
32
|
+
symbols, _deps = PythonASTParser.parse_source("test.py", "def hello(): pass")
|
|
33
|
+
ast_ok = len(symbols) == 1 and symbols[0].name == "hello"
|
|
34
|
+
ast_status = "PASS" if ast_ok else "FAIL"
|
|
35
|
+
except Exception as e:
|
|
36
|
+
ast_status = f"FAIL ({e})"
|
|
37
|
+
sys.stdout.write(f"[{ast_status}] Python AST Static Analyzer: functional\n")
|
|
38
|
+
|
|
39
|
+
# 4. Multi-language TypeScript parser check
|
|
40
|
+
try:
|
|
41
|
+
ts_res = JavaScriptTypeScriptParser().parse_source("test.ts", "function greet(): string { return 'hi'; }")
|
|
42
|
+
ts_ok = len(ts_res.symbols) == 1 and ts_res.symbols[0].name == "greet"
|
|
43
|
+
ts_status = "PASS" if ts_ok else "FAIL"
|
|
44
|
+
except Exception as e:
|
|
45
|
+
ts_status = f"FAIL ({e})"
|
|
46
|
+
sys.stdout.write(f"[{ts_status}] TypeScript/JavaScript Static Parser: functional\n")
|
|
47
|
+
|
|
48
|
+
# 5. External linter (Ruff) check
|
|
49
|
+
ruff_bin = shutil.which("ruff")
|
|
50
|
+
ruff_status = "PASS" if ruff_bin else "INFO"
|
|
51
|
+
sys.stdout.write(f"[{ruff_status}] External Linter (Ruff): {ruff_bin or 'Optional / Not installed'}\n")
|
|
52
|
+
|
|
53
|
+
# 6. Service infrastructure status (informational)
|
|
54
|
+
sys.stdout.write("[INFO] Backend Services (PostgreSQL / Redis): Optional (not required for CLI review)\n")
|
|
55
|
+
sys.stdout.write("=" * 65 + "\n")
|
|
56
|
+
sys.stdout.write(f"System diagnostics complete. {__product__} CLI is operational.\n")
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def build_root_parser() -> argparse.ArgumentParser:
|
|
61
|
+
parser = argparse.ArgumentParser(
|
|
62
|
+
prog="logicfalcon",
|
|
63
|
+
description=f"{__product__} — Fast, precise engineering intelligence. Powered by {__platform__}.",
|
|
64
|
+
)
|
|
65
|
+
parser.add_argument(
|
|
66
|
+
"-v", "--version",
|
|
67
|
+
action="version",
|
|
68
|
+
version=f"{__product__} {__version__} (powered by {__platform__})",
|
|
69
|
+
help="Show program's version number and exit.",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
subparsers = parser.add_subparsers(dest="subcommand", help="Available subcommands")
|
|
73
|
+
|
|
74
|
+
# Subcommand: review
|
|
75
|
+
subparsers.add_parser(
|
|
76
|
+
"review",
|
|
77
|
+
help="Run deterministic repository intelligence & automated code review.",
|
|
78
|
+
add_help=False, # Let review parser handle its own flags
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Subcommand: doctor
|
|
82
|
+
subparsers.add_parser(
|
|
83
|
+
"doctor",
|
|
84
|
+
help="Run environment health check, AST parser capabilities, and tool diagnostic.",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return parser
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def run_main(args: list[str] | None = None) -> int:
|
|
91
|
+
argv = sys.argv[1:] if args is None else args
|
|
92
|
+
|
|
93
|
+
# Handle direct review fallback when arguments start with review flags
|
|
94
|
+
if argv and argv[0].startswith("-") and argv[0] not in ("-v", "--version", "-h", "--help"):
|
|
95
|
+
return run_review_cli(argv)
|
|
96
|
+
|
|
97
|
+
if not argv:
|
|
98
|
+
parser = build_root_parser()
|
|
99
|
+
parser.print_help()
|
|
100
|
+
return 0
|
|
101
|
+
|
|
102
|
+
if argv[0] in ("-v", "--version"):
|
|
103
|
+
sys.stdout.write(f"{__product__} {__version__} (powered by {__platform__})\n")
|
|
104
|
+
return 0
|
|
105
|
+
|
|
106
|
+
if argv[0] in ("-h", "--help"):
|
|
107
|
+
parser = build_root_parser()
|
|
108
|
+
parser.print_help()
|
|
109
|
+
return 0
|
|
110
|
+
|
|
111
|
+
if argv[0] == "doctor":
|
|
112
|
+
return run_doctor()
|
|
113
|
+
|
|
114
|
+
if argv[0] == "review":
|
|
115
|
+
return run_review_cli(argv[1:])
|
|
116
|
+
|
|
117
|
+
# Fallback to standard argparsing
|
|
118
|
+
parser = build_root_parser()
|
|
119
|
+
parsed = parser.parse_args(argv)
|
|
120
|
+
if parsed.subcommand == "doctor":
|
|
121
|
+
return run_doctor()
|
|
122
|
+
elif parsed.subcommand == "review":
|
|
123
|
+
return run_review_cli(argv[1:])
|
|
124
|
+
|
|
125
|
+
parser.print_help()
|
|
126
|
+
return 0
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def main() -> NoReturn:
|
|
130
|
+
sys.exit(run_main())
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == "__main__":
|
|
134
|
+
main()
|
logicfalcon/sdk.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""Programmatic Python SDK for LogicFalcon (Powered by AEGIS AI).
|
|
2
|
+
|
|
3
|
+
Provides high-level programmatic access for automated code reviews, diff inspections,
|
|
4
|
+
remediation verification, and safe patch applications.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from packages.review.domain.models import (
|
|
10
|
+
FindingSeverity,
|
|
11
|
+
ProposedFix,
|
|
12
|
+
ReviewFinding,
|
|
13
|
+
ReviewReport,
|
|
14
|
+
)
|
|
15
|
+
from packages.review.engine import LocalReviewEngine, ReviewConfig
|
|
16
|
+
from packages.review.fix_engine import (
|
|
17
|
+
FixApplicationResult,
|
|
18
|
+
RemediationVerificationResult,
|
|
19
|
+
ReviewFixEngine,
|
|
20
|
+
)
|
|
21
|
+
from packages.review.validator import FindingValidator
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"FindingSeverity",
|
|
25
|
+
"FindingValidator",
|
|
26
|
+
"FixApplicationResult",
|
|
27
|
+
"LocalReviewEngine",
|
|
28
|
+
"ProposedFix",
|
|
29
|
+
"RemediationVerificationResult",
|
|
30
|
+
"ReviewConfig",
|
|
31
|
+
"ReviewFinding",
|
|
32
|
+
"ReviewFixEngine",
|
|
33
|
+
"ReviewReport",
|
|
34
|
+
"apply_fix",
|
|
35
|
+
"review",
|
|
36
|
+
"review_diff",
|
|
37
|
+
"verify_fix",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def review(
|
|
42
|
+
repo: str | Path = ".",
|
|
43
|
+
base: str | None = None,
|
|
44
|
+
staged: bool = False,
|
|
45
|
+
unstaged: bool = False,
|
|
46
|
+
severity_threshold: str = "ERROR",
|
|
47
|
+
config: ReviewConfig | None = None,
|
|
48
|
+
) -> ReviewReport:
|
|
49
|
+
"""Executes a code review on a repository or working tree diff.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
repo: Path to target repository root.
|
|
53
|
+
base: Git commit or branch ref to compare against (e.g. 'origin/main').
|
|
54
|
+
staged: If True, reviews only staged (cached) Git changes.
|
|
55
|
+
unstaged: If True, reviews only unstaged working tree changes.
|
|
56
|
+
severity_threshold: Minimum severity to trigger failure.
|
|
57
|
+
config: Custom ReviewConfig options.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
ReviewReport containing findings, affected artifacts, and execution metrics.
|
|
61
|
+
"""
|
|
62
|
+
repo_path = Path(repo).resolve()
|
|
63
|
+
engine_config = config or ReviewConfig()
|
|
64
|
+
engine = LocalReviewEngine(repo_root=repo_path, config=engine_config)
|
|
65
|
+
|
|
66
|
+
report = engine.review_local_git_diff(
|
|
67
|
+
base_ref=base,
|
|
68
|
+
staged=staged,
|
|
69
|
+
unstaged=unstaged,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
validator = FindingValidator(repo_root=repo_path)
|
|
73
|
+
verified, _ = validator.validate(report.findings)
|
|
74
|
+
report.findings = verified
|
|
75
|
+
return report
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def review_diff(
|
|
79
|
+
diff_text: str,
|
|
80
|
+
repo_root: str | Path = ".",
|
|
81
|
+
config: ReviewConfig | None = None,
|
|
82
|
+
) -> ReviewReport:
|
|
83
|
+
"""Synchronously reviews a raw unified Git diff string.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
diff_text: Unified git diff formatted text.
|
|
87
|
+
repo_root: Path to repository root for context and validation.
|
|
88
|
+
config: Custom ReviewConfig options.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
ReviewReport containing findings and analysis metadata.
|
|
92
|
+
"""
|
|
93
|
+
repo_path = Path(repo_root).resolve()
|
|
94
|
+
engine_config = config or ReviewConfig()
|
|
95
|
+
engine = LocalReviewEngine(repo_root=repo_path, config=engine_config)
|
|
96
|
+
report = engine.review_diff(diff_text=diff_text)
|
|
97
|
+
|
|
98
|
+
diff_summary = engine.diff_parser.parse(diff_text)
|
|
99
|
+
validator = FindingValidator(repo_root=repo_path)
|
|
100
|
+
verified, _ = validator.validate(report.findings, diff_summary=diff_summary)
|
|
101
|
+
report.findings = verified
|
|
102
|
+
return report
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def apply_fix(
|
|
106
|
+
fix: ProposedFix,
|
|
107
|
+
approved: bool = False,
|
|
108
|
+
repo_root: str | Path = ".",
|
|
109
|
+
dry_run: bool = False,
|
|
110
|
+
validate_syntax: bool = True,
|
|
111
|
+
create_backup: bool = True,
|
|
112
|
+
) -> FixApplicationResult:
|
|
113
|
+
"""Safely applies a proposed remediation fix to disk.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
fix: ProposedFix object to apply.
|
|
117
|
+
approved: Explicit developer confirmation (required if dry_run=False).
|
|
118
|
+
repo_root: Target repository root.
|
|
119
|
+
dry_run: If True, returns unified diff preview without modifying disk.
|
|
120
|
+
validate_syntax: If True, checks python syntax before writing.
|
|
121
|
+
create_backup: If True, creates a .bak copy before modifying.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
FixApplicationResult with execution status and diff.
|
|
125
|
+
"""
|
|
126
|
+
repo_path = Path(repo_root).resolve()
|
|
127
|
+
fix_engine = ReviewFixEngine(repo_root=repo_path)
|
|
128
|
+
return fix_engine.apply_fix(
|
|
129
|
+
fix=fix,
|
|
130
|
+
approved=approved,
|
|
131
|
+
dry_run=dry_run,
|
|
132
|
+
validate_syntax=validate_syntax,
|
|
133
|
+
create_backup=create_backup,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def verify_fix(
|
|
138
|
+
fixes: list[ProposedFix],
|
|
139
|
+
repo_root: str | Path = ".",
|
|
140
|
+
run_tests: bool = True,
|
|
141
|
+
run_linters: bool = True,
|
|
142
|
+
test_command: list[str] | None = None,
|
|
143
|
+
lint_command: list[str] | None = None,
|
|
144
|
+
) -> RemediationVerificationResult:
|
|
145
|
+
"""Applies fixes in an isolated workspace and runs real tests and linters.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
fixes: List of ProposedFix objects to verify.
|
|
149
|
+
repo_root: Target repository root.
|
|
150
|
+
run_tests: Whether to execute tests in the isolated workspace.
|
|
151
|
+
run_linters: Whether to execute linters in the isolated workspace.
|
|
152
|
+
test_command: Custom test command list (e.g. ['pytest', 'tests/']).
|
|
153
|
+
lint_command: Custom linter command list (e.g. ['ruff', 'check', '.']).
|
|
154
|
+
|
|
155
|
+
Returns:
|
|
156
|
+
RemediationVerificationResult indicating whether the fix passed QA.
|
|
157
|
+
"""
|
|
158
|
+
repo_path = Path(repo_root).resolve()
|
|
159
|
+
fix_engine = ReviewFixEngine(repo_root=repo_path)
|
|
160
|
+
return fix_engine.verify_remediation(
|
|
161
|
+
fixes=fixes,
|
|
162
|
+
run_tests=run_tests,
|
|
163
|
+
run_linters=run_linters,
|
|
164
|
+
test_command=test_command,
|
|
165
|
+
lint_command=lint_command,
|
|
166
|
+
)
|