amd-gaia 0.15.0__py3-none-any.whl → 0.15.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.
Files changed (181) hide show
  1. {amd_gaia-0.15.0.dist-info → amd_gaia-0.15.1.dist-info}/METADATA +223 -223
  2. amd_gaia-0.15.1.dist-info/RECORD +178 -0
  3. {amd_gaia-0.15.0.dist-info → amd_gaia-0.15.1.dist-info}/entry_points.txt +1 -0
  4. {amd_gaia-0.15.0.dist-info → amd_gaia-0.15.1.dist-info}/licenses/LICENSE.md +20 -20
  5. gaia/__init__.py +29 -29
  6. gaia/agents/__init__.py +19 -19
  7. gaia/agents/base/__init__.py +9 -9
  8. gaia/agents/base/agent.py +2177 -2177
  9. gaia/agents/base/api_agent.py +120 -120
  10. gaia/agents/base/console.py +1841 -1841
  11. gaia/agents/base/errors.py +237 -237
  12. gaia/agents/base/mcp_agent.py +86 -86
  13. gaia/agents/base/tools.py +83 -83
  14. gaia/agents/blender/agent.py +556 -556
  15. gaia/agents/blender/agent_simple.py +133 -135
  16. gaia/agents/blender/app.py +211 -211
  17. gaia/agents/blender/app_simple.py +41 -41
  18. gaia/agents/blender/core/__init__.py +16 -16
  19. gaia/agents/blender/core/materials.py +506 -506
  20. gaia/agents/blender/core/objects.py +316 -316
  21. gaia/agents/blender/core/rendering.py +225 -225
  22. gaia/agents/blender/core/scene.py +220 -220
  23. gaia/agents/blender/core/view.py +146 -146
  24. gaia/agents/chat/__init__.py +9 -9
  25. gaia/agents/chat/agent.py +835 -835
  26. gaia/agents/chat/app.py +1058 -1058
  27. gaia/agents/chat/session.py +508 -508
  28. gaia/agents/chat/tools/__init__.py +15 -15
  29. gaia/agents/chat/tools/file_tools.py +96 -96
  30. gaia/agents/chat/tools/rag_tools.py +1729 -1729
  31. gaia/agents/chat/tools/shell_tools.py +436 -436
  32. gaia/agents/code/__init__.py +7 -7
  33. gaia/agents/code/agent.py +549 -549
  34. gaia/agents/code/cli.py +377 -0
  35. gaia/agents/code/models.py +135 -135
  36. gaia/agents/code/orchestration/__init__.py +24 -24
  37. gaia/agents/code/orchestration/checklist_executor.py +1763 -1763
  38. gaia/agents/code/orchestration/checklist_generator.py +713 -713
  39. gaia/agents/code/orchestration/factories/__init__.py +9 -9
  40. gaia/agents/code/orchestration/factories/base.py +63 -63
  41. gaia/agents/code/orchestration/factories/nextjs_factory.py +118 -118
  42. gaia/agents/code/orchestration/factories/python_factory.py +106 -106
  43. gaia/agents/code/orchestration/orchestrator.py +841 -841
  44. gaia/agents/code/orchestration/project_analyzer.py +391 -391
  45. gaia/agents/code/orchestration/steps/__init__.py +67 -67
  46. gaia/agents/code/orchestration/steps/base.py +188 -188
  47. gaia/agents/code/orchestration/steps/error_handler.py +314 -314
  48. gaia/agents/code/orchestration/steps/nextjs.py +828 -828
  49. gaia/agents/code/orchestration/steps/python.py +307 -307
  50. gaia/agents/code/orchestration/template_catalog.py +469 -469
  51. gaia/agents/code/orchestration/workflows/__init__.py +14 -14
  52. gaia/agents/code/orchestration/workflows/base.py +80 -80
  53. gaia/agents/code/orchestration/workflows/nextjs.py +186 -186
  54. gaia/agents/code/orchestration/workflows/python.py +94 -94
  55. gaia/agents/code/prompts/__init__.py +11 -11
  56. gaia/agents/code/prompts/base_prompt.py +77 -77
  57. gaia/agents/code/prompts/code_patterns.py +2036 -2036
  58. gaia/agents/code/prompts/nextjs_prompt.py +40 -40
  59. gaia/agents/code/prompts/python_prompt.py +109 -109
  60. gaia/agents/code/schema_inference.py +365 -365
  61. gaia/agents/code/system_prompt.py +41 -41
  62. gaia/agents/code/tools/__init__.py +42 -42
  63. gaia/agents/code/tools/cli_tools.py +1138 -1138
  64. gaia/agents/code/tools/code_formatting.py +319 -319
  65. gaia/agents/code/tools/code_tools.py +769 -769
  66. gaia/agents/code/tools/error_fixing.py +1347 -1347
  67. gaia/agents/code/tools/external_tools.py +180 -180
  68. gaia/agents/code/tools/file_io.py +845 -845
  69. gaia/agents/code/tools/prisma_tools.py +190 -190
  70. gaia/agents/code/tools/project_management.py +1016 -1016
  71. gaia/agents/code/tools/testing.py +321 -321
  72. gaia/agents/code/tools/typescript_tools.py +122 -122
  73. gaia/agents/code/tools/validation_parsing.py +461 -461
  74. gaia/agents/code/tools/validation_tools.py +806 -806
  75. gaia/agents/code/tools/web_dev_tools.py +1758 -1758
  76. gaia/agents/code/validators/__init__.py +16 -16
  77. gaia/agents/code/validators/antipattern_checker.py +241 -241
  78. gaia/agents/code/validators/ast_analyzer.py +197 -197
  79. gaia/agents/code/validators/requirements_validator.py +145 -145
  80. gaia/agents/code/validators/syntax_validator.py +171 -171
  81. gaia/agents/docker/__init__.py +7 -7
  82. gaia/agents/docker/agent.py +642 -642
  83. gaia/agents/emr/__init__.py +8 -8
  84. gaia/agents/emr/agent.py +1506 -1506
  85. gaia/agents/emr/cli.py +1322 -1322
  86. gaia/agents/emr/constants.py +475 -475
  87. gaia/agents/emr/dashboard/__init__.py +4 -4
  88. gaia/agents/emr/dashboard/server.py +1974 -1974
  89. gaia/agents/jira/__init__.py +11 -11
  90. gaia/agents/jira/agent.py +894 -894
  91. gaia/agents/jira/jql_templates.py +299 -299
  92. gaia/agents/routing/__init__.py +7 -7
  93. gaia/agents/routing/agent.py +567 -570
  94. gaia/agents/routing/system_prompt.py +75 -75
  95. gaia/agents/summarize/__init__.py +11 -0
  96. gaia/agents/summarize/agent.py +885 -0
  97. gaia/agents/summarize/prompts.py +129 -0
  98. gaia/api/__init__.py +23 -23
  99. gaia/api/agent_registry.py +238 -238
  100. gaia/api/app.py +305 -305
  101. gaia/api/openai_server.py +575 -575
  102. gaia/api/schemas.py +186 -186
  103. gaia/api/sse_handler.py +373 -373
  104. gaia/apps/__init__.py +4 -4
  105. gaia/apps/llm/__init__.py +6 -6
  106. gaia/apps/llm/app.py +173 -169
  107. gaia/apps/summarize/app.py +116 -633
  108. gaia/apps/summarize/html_viewer.py +133 -133
  109. gaia/apps/summarize/pdf_formatter.py +284 -284
  110. gaia/audio/__init__.py +2 -2
  111. gaia/audio/audio_client.py +439 -439
  112. gaia/audio/audio_recorder.py +269 -269
  113. gaia/audio/kokoro_tts.py +599 -599
  114. gaia/audio/whisper_asr.py +432 -432
  115. gaia/chat/__init__.py +16 -16
  116. gaia/chat/app.py +430 -430
  117. gaia/chat/prompts.py +522 -522
  118. gaia/chat/sdk.py +1228 -1225
  119. gaia/cli.py +5481 -5632
  120. gaia/database/__init__.py +10 -10
  121. gaia/database/agent.py +176 -176
  122. gaia/database/mixin.py +290 -290
  123. gaia/database/testing.py +64 -64
  124. gaia/eval/batch_experiment.py +2332 -2332
  125. gaia/eval/claude.py +542 -542
  126. gaia/eval/config.py +37 -37
  127. gaia/eval/email_generator.py +512 -512
  128. gaia/eval/eval.py +3179 -3179
  129. gaia/eval/groundtruth.py +1130 -1130
  130. gaia/eval/transcript_generator.py +582 -582
  131. gaia/eval/webapp/README.md +167 -167
  132. gaia/eval/webapp/package-lock.json +875 -875
  133. gaia/eval/webapp/package.json +20 -20
  134. gaia/eval/webapp/public/app.js +3402 -3402
  135. gaia/eval/webapp/public/index.html +87 -87
  136. gaia/eval/webapp/public/styles.css +3661 -3661
  137. gaia/eval/webapp/server.js +415 -415
  138. gaia/eval/webapp/test-setup.js +72 -72
  139. gaia/llm/__init__.py +9 -2
  140. gaia/llm/base_client.py +60 -0
  141. gaia/llm/exceptions.py +12 -0
  142. gaia/llm/factory.py +70 -0
  143. gaia/llm/lemonade_client.py +3236 -3221
  144. gaia/llm/lemonade_manager.py +294 -294
  145. gaia/llm/providers/__init__.py +9 -0
  146. gaia/llm/providers/claude.py +108 -0
  147. gaia/llm/providers/lemonade.py +120 -0
  148. gaia/llm/providers/openai_provider.py +79 -0
  149. gaia/llm/vlm_client.py +382 -382
  150. gaia/logger.py +189 -189
  151. gaia/mcp/agent_mcp_server.py +245 -245
  152. gaia/mcp/blender_mcp_client.py +138 -138
  153. gaia/mcp/blender_mcp_server.py +648 -648
  154. gaia/mcp/context7_cache.py +332 -332
  155. gaia/mcp/external_services.py +518 -518
  156. gaia/mcp/mcp_bridge.py +811 -550
  157. gaia/mcp/servers/__init__.py +6 -6
  158. gaia/mcp/servers/docker_mcp.py +83 -83
  159. gaia/perf_analysis.py +361 -0
  160. gaia/rag/__init__.py +10 -10
  161. gaia/rag/app.py +293 -293
  162. gaia/rag/demo.py +304 -304
  163. gaia/rag/pdf_utils.py +235 -235
  164. gaia/rag/sdk.py +2194 -2194
  165. gaia/security.py +163 -163
  166. gaia/talk/app.py +289 -289
  167. gaia/talk/sdk.py +538 -538
  168. gaia/testing/__init__.py +87 -87
  169. gaia/testing/assertions.py +330 -330
  170. gaia/testing/fixtures.py +333 -333
  171. gaia/testing/mocks.py +493 -493
  172. gaia/util.py +46 -46
  173. gaia/utils/__init__.py +33 -33
  174. gaia/utils/file_watcher.py +675 -675
  175. gaia/utils/parsing.py +223 -223
  176. gaia/version.py +100 -100
  177. amd_gaia-0.15.0.dist-info/RECORD +0 -168
  178. gaia/agents/code/app.py +0 -266
  179. gaia/llm/llm_client.py +0 -723
  180. {amd_gaia-0.15.0.dist-info → amd_gaia-0.15.1.dist-info}/WHEEL +0 -0
  181. {amd_gaia-0.15.0.dist-info → amd_gaia-0.15.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,377 @@
1
+ # Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """CLI for Code Agent."""
5
+
6
+ import argparse
7
+ import json
8
+ import logging
9
+ import os
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ from rich.console import Console
14
+
15
+ logger = logging.getLogger(__name__)
16
+ console = Console()
17
+
18
+
19
+ def _run_interactive_mode(agent, project_path, args, log):
20
+ """Run the interactive REPL loop for the Code Agent."""
21
+ while True:
22
+ try:
23
+ query = input("\ncode> ").strip()
24
+
25
+ if query.lower() in ["exit", "quit"]:
26
+ log.info("Goodbye!")
27
+ break
28
+
29
+ if query.lower() == "help":
30
+ print("\nAvailable commands:")
31
+ print(" Generate functions, classes, or tests")
32
+ print(" Analyze Python files")
33
+ print(" Validate Python syntax")
34
+ print(" Lint and format code")
35
+ print(" Edit files with diffs")
36
+ print(" Search for code patterns")
37
+ print(" Type 'exit' or 'quit' to end")
38
+ continue
39
+
40
+ if not query:
41
+ continue
42
+
43
+ # Process the query
44
+ result = agent.process_query(
45
+ query,
46
+ workspace_root=project_path,
47
+ max_steps=args.max_steps,
48
+ trace=args.trace,
49
+ )
50
+
51
+ # Display result
52
+ if not args.silent:
53
+ if result.get("status") == "success":
54
+ log.info(f"\n✅ {result.get('result', 'Task completed')}")
55
+ else:
56
+ log.error(f"\n❌ {result.get('result', 'Task failed')}")
57
+
58
+ except KeyboardInterrupt:
59
+ print("\n\nInterrupted. Type 'exit' to quit.")
60
+ continue
61
+ except Exception as e:
62
+ log.error(f"Error processing query: {e}")
63
+ if args.debug:
64
+ import traceback
65
+
66
+ traceback.print_exc()
67
+
68
+
69
+ def cmd_run(args):
70
+ """Run the Code Agent with a query."""
71
+ from gaia.logger import get_logger
72
+
73
+ log = get_logger(__name__)
74
+
75
+ # Set logging level to DEBUG if --debug flag is used
76
+ if args.debug:
77
+ from gaia.logger import log_manager
78
+
79
+ # Set root logger level first to ensure all handlers process DEBUG messages
80
+ root_logger = logging.getLogger()
81
+ root_logger.setLevel(logging.DEBUG)
82
+
83
+ # Update all existing loggers that start with "gaia"
84
+ for logger_name in list(log_manager.loggers.keys()):
85
+ if logger_name.startswith("gaia"):
86
+ log_manager.loggers[logger_name].setLevel(logging.DEBUG)
87
+
88
+ # Set default level for future loggers
89
+ log_manager.set_level("gaia", logging.DEBUG)
90
+
91
+ # Also ensure all handlers have DEBUG level
92
+ for handler in root_logger.handlers:
93
+ handler.setLevel(logging.DEBUG)
94
+
95
+ # Check if code agent is available
96
+ try:
97
+ from gaia.agents.code.agent import CodeAgent # noqa: F401
98
+
99
+ CODE_AVAILABLE = True
100
+ except ImportError:
101
+ CODE_AVAILABLE = False
102
+
103
+ if not CODE_AVAILABLE:
104
+ log.error("Code agent is not available. Please check your installation.")
105
+ return 1
106
+
107
+ # Get base_url from args or environment
108
+ base_url = args.base_url
109
+ if base_url is None:
110
+ base_url = os.getenv("LEMONADE_BASE_URL", "http://localhost:8000/api/v1")
111
+
112
+ # Initialize Lemonade with code agent profile (32768 context)
113
+ # Skip for remote servers (e.g., devtunnel URLs), external APIs, or --no-lemonade-check
114
+ is_local = "localhost" in base_url or "127.0.0.1" in base_url
115
+ skip_lemonade = args.no_lemonade_check
116
+ if is_local and not skip_lemonade:
117
+ from gaia.cli import initialize_lemonade_for_agent
118
+
119
+ success, _ = initialize_lemonade_for_agent(
120
+ agent="code",
121
+ skip_if_external=True,
122
+ use_claude=args.use_claude,
123
+ use_chatgpt=args.use_chatgpt,
124
+ )
125
+ if not success:
126
+ return 1
127
+
128
+ try:
129
+ # Import RoutingAgent for intelligent language detection
130
+ from gaia.agents.routing.agent import RoutingAgent
131
+
132
+ # Handle --path argument
133
+ project_path = args.path if hasattr(args, "path") else None
134
+ if project_path:
135
+ project_path = Path(project_path).expanduser().resolve()
136
+ # Create directory if it doesn't exist
137
+ project_path.mkdir(parents=True, exist_ok=True)
138
+ project_path = str(project_path)
139
+ log.debug(f"Using project path: {project_path}")
140
+
141
+ # Get the query to analyze
142
+ query = args.query if hasattr(args, "query") and args.query else None
143
+
144
+ # Use RoutingAgent to determine language and project type
145
+ if query:
146
+ # Prepare agent configuration from CLI args
147
+ agent_config = {
148
+ "silent_mode": args.silent,
149
+ "debug": args.debug,
150
+ "show_prompts": args.show_prompts,
151
+ "max_steps": args.max_steps,
152
+ "use_claude": args.use_claude,
153
+ "use_chatgpt": args.use_chatgpt,
154
+ "streaming": args.stream,
155
+ "base_url": args.base_url,
156
+ "skip_lemonade": args.no_lemonade_check,
157
+ }
158
+
159
+ # Single query mode - use routing with configuration
160
+ router = RoutingAgent(**agent_config)
161
+ agent = router.process_query(query)
162
+ else:
163
+ # Interactive mode - start with default Python agent
164
+ # User can still benefit from routing per query
165
+ agent = CodeAgent(
166
+ silent_mode=args.silent,
167
+ debug=args.debug,
168
+ show_prompts=args.show_prompts,
169
+ max_steps=args.max_steps,
170
+ use_claude=args.use_claude,
171
+ use_chatgpt=args.use_chatgpt,
172
+ streaming=args.stream,
173
+ base_url=args.base_url,
174
+ skip_lemonade=args.no_lemonade_check,
175
+ )
176
+
177
+ # Handle list tools option
178
+ if args.list_tools:
179
+ agent.list_tools(verbose=True)
180
+ return 0
181
+
182
+ # Handle interactive mode
183
+ if args.interactive:
184
+ log.info("🤖 Code Agent Interactive Mode")
185
+ log.info("Type 'exit' or 'quit' to end the session")
186
+ log.info("Type 'help' for available commands\n")
187
+
188
+ _run_interactive_mode(agent, project_path, args, log)
189
+ return 0
190
+
191
+ # Single query mode
192
+ elif query:
193
+ result = agent.process_query(
194
+ query,
195
+ workspace_root=project_path,
196
+ max_steps=args.max_steps,
197
+ trace=args.trace,
198
+ step_through=args.step_through,
199
+ )
200
+
201
+ # Output result
202
+ if args.silent:
203
+ # In silent mode, output only JSON
204
+ print(json.dumps(result, indent=2))
205
+ else:
206
+ # Display formatted result
207
+ agent.display_result("Code Operation Result", result)
208
+
209
+ return 0 if result.get("status") == "success" else 1
210
+
211
+ else:
212
+ # Default to interactive mode when no query provided
213
+ log.info("Starting Code Agent interactive mode (type 'help' for commands)")
214
+
215
+ _run_interactive_mode(agent, project_path, args, log)
216
+ return 0
217
+
218
+ except Exception as e:
219
+ log.error(f"Error initializing Code agent: {e}")
220
+ if args.debug:
221
+ import traceback
222
+
223
+ traceback.print_exc()
224
+ return 1
225
+
226
+
227
+ def main():
228
+ """Main CLI entry point."""
229
+ parser = argparse.ArgumentParser(
230
+ description="GAIA Code Agent - AI-powered code generation and analysis",
231
+ formatter_class=argparse.RawDescriptionHelpFormatter,
232
+ epilog="""
233
+ Examples:
234
+ # Generate code with a query
235
+ gaia-code "Build me a todo tracking app using typescript"
236
+
237
+ # Work in a specific directory
238
+ gaia-code "Build me a todo app" --path ~/src/todo-app
239
+
240
+ # Interactive mode
241
+ gaia-code --interactive
242
+ gaia-code -i
243
+
244
+ # List available tools
245
+ gaia-code --list-tools
246
+
247
+ # Use external LLM APIs
248
+ gaia-code "Build an app" --use-claude
249
+ gaia-code "Build an app" --use-chatgpt
250
+
251
+ # Debug mode
252
+ gaia-code "Build an app" --debug
253
+ """,
254
+ )
255
+
256
+ # Positional argument - the code query
257
+ parser.add_argument(
258
+ "query",
259
+ nargs="?",
260
+ help="Code operation query (e.g., 'Build me a todo app')",
261
+ )
262
+
263
+ # Mode flags
264
+ parser.add_argument(
265
+ "--interactive",
266
+ "-i",
267
+ action="store_true",
268
+ help="Interactive mode for multiple queries",
269
+ )
270
+ parser.add_argument(
271
+ "--list-tools",
272
+ action="store_true",
273
+ help="List all available tools and exit",
274
+ )
275
+
276
+ # Project configuration
277
+ parser.add_argument(
278
+ "--path",
279
+ "-p",
280
+ type=str,
281
+ default=None,
282
+ help="Project directory path. Creates directory if it doesn't exist.",
283
+ )
284
+
285
+ # Debug and output options
286
+ parser.add_argument(
287
+ "--debug",
288
+ action="store_true",
289
+ help="Enable debug logging",
290
+ )
291
+ parser.add_argument(
292
+ "--silent",
293
+ "-s",
294
+ action="store_true",
295
+ help="Silent mode - suppress console output, return JSON only",
296
+ )
297
+ parser.add_argument(
298
+ "--step-through",
299
+ action="store_true",
300
+ help="Enable step-through debugging mode (pause at each agent step)",
301
+ )
302
+ parser.add_argument(
303
+ "--show-prompts",
304
+ action="store_true",
305
+ help="Display prompts sent to LLM",
306
+ )
307
+ parser.add_argument(
308
+ "--trace",
309
+ action="store_true",
310
+ help="Save conversation trace to JSON file",
311
+ )
312
+
313
+ # LLM backend options
314
+ parser.add_argument(
315
+ "--use-claude",
316
+ action="store_true",
317
+ help="Use Claude API instead of local Lemonade server",
318
+ )
319
+ parser.add_argument(
320
+ "--use-chatgpt",
321
+ action="store_true",
322
+ help="Use ChatGPT/OpenAI API instead of local Lemonade server",
323
+ )
324
+ parser.add_argument(
325
+ "--base-url",
326
+ default=None,
327
+ help="Lemonade server URL (default: http://localhost:8000/api/v1)",
328
+ )
329
+ parser.add_argument(
330
+ "--no-lemonade-check",
331
+ action="store_true",
332
+ help="Skip Lemonade server initialization check",
333
+ )
334
+
335
+ # Agent configuration
336
+ parser.add_argument(
337
+ "--max-steps",
338
+ type=int,
339
+ default=100,
340
+ help="Maximum conversation steps (default: 100)",
341
+ )
342
+ parser.add_argument(
343
+ "--stream",
344
+ action="store_true",
345
+ help="Enable streaming responses",
346
+ )
347
+
348
+ # Parse args
349
+ args = parser.parse_args()
350
+
351
+ # Configure logging - WARNING by default, DEBUG with --debug flag
352
+ if args.debug:
353
+ logging.basicConfig(
354
+ level=logging.DEBUG,
355
+ format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
356
+ datefmt="%H:%M:%S",
357
+ )
358
+ else:
359
+ # Suppress logs from gaia modules for cleaner output
360
+ logging.basicConfig(level=logging.WARNING)
361
+ for logger_name in ["gaia", "gaia.llm", "gaia.agents"]:
362
+ logging.getLogger(logger_name).setLevel(logging.WARNING)
363
+
364
+ # Run command
365
+ try:
366
+ return cmd_run(args)
367
+ except Exception as e:
368
+ console.print(f"[red]Error: {e}[/red]")
369
+ if args.debug:
370
+ import traceback
371
+
372
+ traceback.print_exc()
373
+ return 1
374
+
375
+
376
+ if __name__ == "__main__":
377
+ sys.exit(main())
@@ -1,135 +1,135 @@
1
- #!/usr/bin/env python
2
- # Copyright(C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
3
- # SPDX-License-Identifier: MIT
4
- """
5
- Data models for the Code Agent.
6
-
7
- This module contains all data classes and type definitions used across
8
- the code agent modules.
9
- """
10
-
11
- import ast
12
- from dataclasses import dataclass, field
13
- from typing import Any, Dict, List, Optional
14
-
15
-
16
- @dataclass
17
- class CodeSymbol:
18
- """Represents a code symbol (function, class, variable)."""
19
-
20
- name: str
21
- type: str # 'function', 'class', 'variable', 'import'
22
- line: int
23
- docstring: Optional[str] = None
24
- signature: Optional[str] = None
25
-
26
-
27
- @dataclass
28
- class ParsedCode:
29
- """Result of parsing Python code."""
30
-
31
- ast_tree: Optional[ast.Module] = None
32
- symbols: List[CodeSymbol] = field(default_factory=list)
33
- imports: List[str] = field(default_factory=list)
34
- errors: List[str] = field(default_factory=list)
35
- is_valid: bool = False
36
-
37
-
38
- @dataclass
39
- class ModuleSpec:
40
- """Specification for a module in a project."""
41
-
42
- name: str
43
- purpose: str
44
- classes: List[Dict[str, Any]] = field(default_factory=list)
45
- functions: List[Dict[str, Any]] = field(default_factory=list)
46
-
47
-
48
- @dataclass
49
- class TestSpec:
50
- """Specification for a test module."""
51
-
52
- name: str
53
- coverage: str
54
- test_cases: List[str] = field(default_factory=list)
55
-
56
-
57
- @dataclass
58
- class ProjectPlan:
59
- """Complete project plan with architecture and modules."""
60
-
61
- name: str
62
- architecture: Dict[str, Any]
63
- modules: List[ModuleSpec]
64
- tests: List[TestSpec]
65
- description: str = ""
66
- project_type: str = "application"
67
-
68
-
69
- @dataclass
70
- class ValidationResult:
71
- """Result of code validation."""
72
-
73
- is_valid: bool
74
- errors: List[str] = field(default_factory=list)
75
- warnings: List[str] = field(default_factory=list)
76
- fixes_applied: List[str] = field(default_factory=list)
77
- file_modified: bool = False
78
-
79
-
80
- @dataclass
81
- class MethodSpec:
82
- """Specification for a class method."""
83
-
84
- name: str
85
- params: str = "self"
86
- docstring: str = "Method description."
87
- body: str = "pass"
88
- return_type: Optional[str] = None
89
-
90
-
91
- @dataclass
92
- class ProjectStructure:
93
- """Represents a complete project structure."""
94
-
95
- name: str
96
- files: Dict[str, str] # filename -> content
97
- structure: Dict[str, Any] # nested directory structure
98
- plan: Optional[ProjectPlan] = None
99
-
100
-
101
- @dataclass
102
- class WorkflowPlan:
103
- """Plan for executing a coding workflow."""
104
-
105
- query: str
106
- steps: List[Dict[str, Any]]
107
- current_step: int = 0
108
- completed_steps: List[int] = field(default_factory=list)
109
- status: str = "pending" # pending, in_progress, completed, failed
110
-
111
-
112
- @dataclass
113
- class LintIssue:
114
- """Represents a linting issue found by pylint."""
115
-
116
- type: str # error, warning, convention, refactor
117
- message: str
118
- file: str
119
- line: int
120
- column: int = 0
121
- symbol: Optional[str] = None
122
-
123
-
124
- @dataclass
125
- class ExecutionResult:
126
- """Result of executing Python code."""
127
-
128
- stdout: str
129
- stderr: str
130
- return_code: int
131
- has_errors: bool
132
- duration_seconds: float
133
- timed_out: bool = False
134
- file_path: Optional[str] = None
135
- command: Optional[str] = None
1
+ #!/usr/bin/env python
2
+ # Copyright(C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
3
+ # SPDX-License-Identifier: MIT
4
+ """
5
+ Data models for the Code Agent.
6
+
7
+ This module contains all data classes and type definitions used across
8
+ the code agent modules.
9
+ """
10
+
11
+ import ast
12
+ from dataclasses import dataclass, field
13
+ from typing import Any, Dict, List, Optional
14
+
15
+
16
+ @dataclass
17
+ class CodeSymbol:
18
+ """Represents a code symbol (function, class, variable)."""
19
+
20
+ name: str
21
+ type: str # 'function', 'class', 'variable', 'import'
22
+ line: int
23
+ docstring: Optional[str] = None
24
+ signature: Optional[str] = None
25
+
26
+
27
+ @dataclass
28
+ class ParsedCode:
29
+ """Result of parsing Python code."""
30
+
31
+ ast_tree: Optional[ast.Module] = None
32
+ symbols: List[CodeSymbol] = field(default_factory=list)
33
+ imports: List[str] = field(default_factory=list)
34
+ errors: List[str] = field(default_factory=list)
35
+ is_valid: bool = False
36
+
37
+
38
+ @dataclass
39
+ class ModuleSpec:
40
+ """Specification for a module in a project."""
41
+
42
+ name: str
43
+ purpose: str
44
+ classes: List[Dict[str, Any]] = field(default_factory=list)
45
+ functions: List[Dict[str, Any]] = field(default_factory=list)
46
+
47
+
48
+ @dataclass
49
+ class TestSpec:
50
+ """Specification for a test module."""
51
+
52
+ name: str
53
+ coverage: str
54
+ test_cases: List[str] = field(default_factory=list)
55
+
56
+
57
+ @dataclass
58
+ class ProjectPlan:
59
+ """Complete project plan with architecture and modules."""
60
+
61
+ name: str
62
+ architecture: Dict[str, Any]
63
+ modules: List[ModuleSpec]
64
+ tests: List[TestSpec]
65
+ description: str = ""
66
+ project_type: str = "application"
67
+
68
+
69
+ @dataclass
70
+ class ValidationResult:
71
+ """Result of code validation."""
72
+
73
+ is_valid: bool
74
+ errors: List[str] = field(default_factory=list)
75
+ warnings: List[str] = field(default_factory=list)
76
+ fixes_applied: List[str] = field(default_factory=list)
77
+ file_modified: bool = False
78
+
79
+
80
+ @dataclass
81
+ class MethodSpec:
82
+ """Specification for a class method."""
83
+
84
+ name: str
85
+ params: str = "self"
86
+ docstring: str = "Method description."
87
+ body: str = "pass"
88
+ return_type: Optional[str] = None
89
+
90
+
91
+ @dataclass
92
+ class ProjectStructure:
93
+ """Represents a complete project structure."""
94
+
95
+ name: str
96
+ files: Dict[str, str] # filename -> content
97
+ structure: Dict[str, Any] # nested directory structure
98
+ plan: Optional[ProjectPlan] = None
99
+
100
+
101
+ @dataclass
102
+ class WorkflowPlan:
103
+ """Plan for executing a coding workflow."""
104
+
105
+ query: str
106
+ steps: List[Dict[str, Any]]
107
+ current_step: int = 0
108
+ completed_steps: List[int] = field(default_factory=list)
109
+ status: str = "pending" # pending, in_progress, completed, failed
110
+
111
+
112
+ @dataclass
113
+ class LintIssue:
114
+ """Represents a linting issue found by pylint."""
115
+
116
+ type: str # error, warning, convention, refactor
117
+ message: str
118
+ file: str
119
+ line: int
120
+ column: int = 0
121
+ symbol: Optional[str] = None
122
+
123
+
124
+ @dataclass
125
+ class ExecutionResult:
126
+ """Result of executing Python code."""
127
+
128
+ stdout: str
129
+ stderr: str
130
+ return_code: int
131
+ has_errors: bool
132
+ duration_seconds: float
133
+ timed_out: bool = False
134
+ file_path: Optional[str] = None
135
+ command: Optional[str] = None
@@ -1,24 +1,24 @@
1
- # Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
2
- # SPDX-License-Identifier: MIT
3
- """
4
- Orchestration framework for Code Agent.
5
-
6
- This module provides LLM-driven workflow orchestration using checklist mode.
7
- The LLM generates a checklist of template invocations, which are then
8
- executed deterministically with error recovery.
9
- """
10
-
11
- from .orchestrator import ExecutionResult, Orchestrator
12
- from .steps.base import BaseStep, ErrorCategory, StepResult, StepStatus, UserContext
13
-
14
- __all__ = [
15
- # Core
16
- "Orchestrator",
17
- "ExecutionResult",
18
- # Steps
19
- "BaseStep",
20
- "StepResult",
21
- "StepStatus",
22
- "ErrorCategory",
23
- "UserContext",
24
- ]
1
+ # Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
2
+ # SPDX-License-Identifier: MIT
3
+ """
4
+ Orchestration framework for Code Agent.
5
+
6
+ This module provides LLM-driven workflow orchestration using checklist mode.
7
+ The LLM generates a checklist of template invocations, which are then
8
+ executed deterministically with error recovery.
9
+ """
10
+
11
+ from .orchestrator import ExecutionResult, Orchestrator
12
+ from .steps.base import BaseStep, ErrorCategory, StepResult, StepStatus, UserContext
13
+
14
+ __all__ = [
15
+ # Core
16
+ "Orchestrator",
17
+ "ExecutionResult",
18
+ # Steps
19
+ "BaseStep",
20
+ "StepResult",
21
+ "StepStatus",
22
+ "ErrorCategory",
23
+ "UserContext",
24
+ ]