ara-cli 0.1.9.77__py3-none-any.whl → 0.1.10.8__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.

Potentially problematic release.


This version of ara-cli might be problematic. Click here for more details.

Files changed (122) hide show
  1. ara_cli/__init__.py +18 -2
  2. ara_cli/__main__.py +245 -66
  3. ara_cli/ara_command_action.py +128 -63
  4. ara_cli/ara_config.py +201 -177
  5. ara_cli/ara_subcommands/__init__.py +0 -0
  6. ara_cli/ara_subcommands/autofix.py +26 -0
  7. ara_cli/ara_subcommands/chat.py +27 -0
  8. ara_cli/ara_subcommands/classifier_directory.py +16 -0
  9. ara_cli/ara_subcommands/common.py +100 -0
  10. ara_cli/ara_subcommands/create.py +75 -0
  11. ara_cli/ara_subcommands/delete.py +22 -0
  12. ara_cli/ara_subcommands/extract.py +22 -0
  13. ara_cli/ara_subcommands/fetch_templates.py +14 -0
  14. ara_cli/ara_subcommands/list.py +65 -0
  15. ara_cli/ara_subcommands/list_tags.py +25 -0
  16. ara_cli/ara_subcommands/load.py +48 -0
  17. ara_cli/ara_subcommands/prompt.py +136 -0
  18. ara_cli/ara_subcommands/read.py +47 -0
  19. ara_cli/ara_subcommands/read_status.py +20 -0
  20. ara_cli/ara_subcommands/read_user.py +20 -0
  21. ara_cli/ara_subcommands/reconnect.py +27 -0
  22. ara_cli/ara_subcommands/rename.py +22 -0
  23. ara_cli/ara_subcommands/scan.py +14 -0
  24. ara_cli/ara_subcommands/set_status.py +22 -0
  25. ara_cli/ara_subcommands/set_user.py +22 -0
  26. ara_cli/ara_subcommands/template.py +16 -0
  27. ara_cli/artefact_autofix.py +214 -28
  28. ara_cli/artefact_creator.py +5 -8
  29. ara_cli/artefact_deleter.py +2 -4
  30. ara_cli/artefact_fuzzy_search.py +13 -6
  31. ara_cli/artefact_lister.py +29 -55
  32. ara_cli/artefact_models/artefact_data_retrieval.py +23 -0
  33. ara_cli/artefact_models/artefact_model.py +106 -25
  34. ara_cli/artefact_models/artefact_templates.py +23 -13
  35. ara_cli/artefact_models/epic_artefact_model.py +11 -2
  36. ara_cli/artefact_models/feature_artefact_model.py +56 -1
  37. ara_cli/artefact_models/userstory_artefact_model.py +15 -3
  38. ara_cli/artefact_reader.py +4 -5
  39. ara_cli/artefact_renamer.py +6 -2
  40. ara_cli/artefact_scan.py +2 -2
  41. ara_cli/chat.py +594 -219
  42. ara_cli/chat_agent/__init__.py +0 -0
  43. ara_cli/chat_agent/agent_communicator.py +62 -0
  44. ara_cli/chat_agent/agent_process_manager.py +211 -0
  45. ara_cli/chat_agent/agent_status_manager.py +73 -0
  46. ara_cli/chat_agent/agent_workspace_manager.py +76 -0
  47. ara_cli/commands/__init__.py +0 -0
  48. ara_cli/commands/command.py +7 -0
  49. ara_cli/commands/extract_command.py +15 -0
  50. ara_cli/commands/load_command.py +65 -0
  51. ara_cli/commands/load_image_command.py +34 -0
  52. ara_cli/commands/read_command.py +117 -0
  53. ara_cli/completers.py +144 -0
  54. ara_cli/directory_navigator.py +37 -4
  55. ara_cli/error_handler.py +134 -0
  56. ara_cli/file_classifier.py +3 -2
  57. ara_cli/file_loaders/__init__.py +0 -0
  58. ara_cli/file_loaders/binary_file_loader.py +33 -0
  59. ara_cli/file_loaders/document_file_loader.py +34 -0
  60. ara_cli/file_loaders/document_reader.py +245 -0
  61. ara_cli/file_loaders/document_readers.py +233 -0
  62. ara_cli/file_loaders/file_loader.py +50 -0
  63. ara_cli/file_loaders/file_loaders.py +123 -0
  64. ara_cli/file_loaders/image_processor.py +89 -0
  65. ara_cli/file_loaders/markdown_reader.py +75 -0
  66. ara_cli/file_loaders/text_file_loader.py +187 -0
  67. ara_cli/global_file_lister.py +51 -0
  68. ara_cli/prompt_extractor.py +214 -87
  69. ara_cli/prompt_handler.py +508 -146
  70. ara_cli/tag_extractor.py +54 -24
  71. ara_cli/template_loader.py +245 -0
  72. ara_cli/template_manager.py +14 -4
  73. ara_cli/templates/prompt-modules/commands/empty.commands.md +2 -12
  74. ara_cli/templates/prompt-modules/commands/extract_general.commands.md +12 -0
  75. ara_cli/templates/prompt-modules/commands/extract_markdown.commands.md +11 -0
  76. ara_cli/templates/prompt-modules/commands/extract_python.commands.md +13 -0
  77. ara_cli/templates/prompt-modules/commands/feature_add_or_modifiy_specified_behavior.commands.md +36 -0
  78. ara_cli/templates/prompt-modules/commands/feature_generate_initial_specified_bevahior.commands.md +53 -0
  79. ara_cli/templates/prompt-modules/commands/prompt_template_tech_stack_transformer.commands.md +95 -0
  80. ara_cli/templates/prompt-modules/commands/python_bug_fixing_code.commands.md +34 -0
  81. ara_cli/templates/prompt-modules/commands/python_generate_code.commands.md +27 -0
  82. ara_cli/templates/prompt-modules/commands/python_refactoring_code.commands.md +39 -0
  83. ara_cli/templates/prompt-modules/commands/python_step_definitions_generation_and_fixing.commands.md +40 -0
  84. ara_cli/templates/prompt-modules/commands/python_unittest_generation_and_fixing.commands.md +48 -0
  85. ara_cli/update_config_prompt.py +7 -1
  86. ara_cli/version.py +1 -1
  87. ara_cli-0.1.10.8.dist-info/METADATA +241 -0
  88. {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/RECORD +104 -59
  89. tests/test_ara_command_action.py +66 -52
  90. tests/test_ara_config.py +200 -279
  91. tests/test_artefact_autofix.py +361 -5
  92. tests/test_artefact_lister.py +52 -132
  93. tests/test_artefact_scan.py +1 -1
  94. tests/test_chat.py +2009 -603
  95. tests/test_file_classifier.py +23 -0
  96. tests/test_file_creator.py +3 -5
  97. tests/test_global_file_lister.py +131 -0
  98. tests/test_prompt_handler.py +746 -0
  99. tests/test_tag_extractor.py +19 -13
  100. tests/test_template_loader.py +192 -0
  101. tests/test_template_manager.py +5 -4
  102. ara_cli/ara_command_parser.py +0 -536
  103. ara_cli/templates/prompt-modules/blueprints/complete_pytest_unittest.blueprint.md +0 -27
  104. ara_cli/templates/prompt-modules/blueprints/task_todo_list_implement_feature_BDD_way.blueprint.md +0 -30
  105. ara_cli/templates/prompt-modules/commands/artefact_classification.commands.md +0 -9
  106. ara_cli/templates/prompt-modules/commands/artefact_extension.commands.md +0 -17
  107. ara_cli/templates/prompt-modules/commands/artefact_formulation.commands.md +0 -14
  108. ara_cli/templates/prompt-modules/commands/behave_step_generation.commands.md +0 -102
  109. ara_cli/templates/prompt-modules/commands/code_generation_complex.commands.md +0 -20
  110. ara_cli/templates/prompt-modules/commands/code_generation_simple.commands.md +0 -13
  111. ara_cli/templates/prompt-modules/commands/error_fixing.commands.md +0 -20
  112. ara_cli/templates/prompt-modules/commands/feature_file_update.commands.md +0 -18
  113. ara_cli/templates/prompt-modules/commands/feature_formulation.commands.md +0 -43
  114. ara_cli/templates/prompt-modules/commands/js_code_generation_simple.commands.md +0 -13
  115. ara_cli/templates/prompt-modules/commands/refactoring.commands.md +0 -15
  116. ara_cli/templates/prompt-modules/commands/refactoring_analysis.commands.md +0 -9
  117. ara_cli/templates/prompt-modules/commands/reverse_engineer_feature_file.commands.md +0 -15
  118. ara_cli/templates/prompt-modules/commands/reverse_engineer_program_flow.commands.md +0 -19
  119. ara_cli-0.1.9.77.dist-info/METADATA +0 -18
  120. {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/WHEEL +0 -0
  121. {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/entry_points.txt +0 -0
  122. {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/top_level.txt +0 -0
ara_cli/__init__.py CHANGED
@@ -1,3 +1,19 @@
1
- from .version import __version__
1
+ import warnings
2
+ from .error_handler import ErrorHandler
2
3
 
3
- whitelisted_commands = ["RERUN", "SEND", "EXTRACT", "LOAD_IMAGE", "CHOOSE_MODEL", "CURRENT_MODEL", "LIST_MODELS"]
4
+
5
+ whitelisted_commands = ["RERUN", "SEND", "EXTRACT", "LOAD_IMAGE", "CHOOSE_MODEL", "CHOOSE_EXTRACTION_MODEL", "CURRENT_MODEL", "CURRENT_EXTRACTION_MODEL", "LIST_MODELS"]
6
+
7
+ error_handler = ErrorHandler()
8
+
9
+
10
+ # ANSI escape codes for coloring
11
+ YELLOW = '\033[93m'
12
+ RESET = '\033[0m'
13
+
14
+
15
+ def format_warning(message, category, *args, **kwargs):
16
+ return f'{YELLOW}[WARNING] {category.__name__}: {message}{RESET}\n'
17
+
18
+
19
+ warnings.formatwarning = format_warning
ara_cli/__main__.py CHANGED
@@ -1,78 +1,257 @@
1
- # PYTHON_ARGCOMPLETE_OK
2
- from ara_cli.ara_command_parser import action_parser
1
+ import typer
2
+ import os
3
+ from typing import Optional
4
+ from os import getenv
3
5
  from ara_cli.version import __version__
4
- from ara_cli.ara_command_action import (
5
- create_action,
6
- delete_action,
7
- rename_action,
8
- list_action,
9
- list_tags_action,
10
- prompt_action,
11
- chat_action,
12
- template_action,
13
- fetch_templates_action,
14
- read_action,
15
- reconnect_action,
16
- read_status_action,
17
- read_user_action,
18
- set_status_action,
19
- set_user_action,
20
- classifier_directory_action,
21
- scan_action,
22
- autofix_action,
23
- )
24
- import argcomplete
25
- import sys
26
-
27
-
28
- def define_action_mapping():
29
- return {
30
- "create": create_action,
31
- "delete": delete_action,
32
- "rename": rename_action,
33
- "list": list_action,
34
- "list-tags": list_tags_action,
35
- "prompt": prompt_action,
36
- "chat": chat_action,
37
- "template": template_action,
38
- "fetch-templates": fetch_templates_action,
39
- "read": read_action,
40
- "reconnect": reconnect_action,
41
- "read-status": read_status_action,
42
- "read-user": read_user_action,
43
- "set-status": set_status_action,
44
- "set-user": set_user_action,
45
- "classifier-directory": classifier_directory_action,
46
- "scan": scan_action,
47
- "autofix": autofix_action,
48
- }
49
-
50
-
51
- def handle_invalid_action(args):
52
- sys.exit("Invalid action provided. Type ara -h for help")
6
+ from ara_cli import error_handler
7
+ from ara_cli.ara_subcommands.create import register as register_create_cli
8
+ from ara_cli.ara_subcommands.delete import register as register_delete_cli
9
+ from ara_cli.ara_subcommands.rename import register as register_rename_cli
10
+ from ara_cli.ara_subcommands.list import register as register_list_cli
11
+ from ara_cli.ara_subcommands.list_tags import register as register_list_tags_cli
12
+ from ara_cli.ara_subcommands.prompt import register as register_prompt_cli
13
+ from ara_cli.ara_subcommands.chat import register as register_chat_cli
14
+ from ara_cli.ara_subcommands.template import register as register_template_cli
15
+ from ara_cli.ara_subcommands.fetch_templates import register as register_fetch_templates_cli
16
+ from ara_cli.ara_subcommands.read import register as register_read_cli
17
+ from ara_cli.ara_subcommands.reconnect import register as register_reconnect_cli
18
+ from ara_cli.ara_subcommands.read_status import register as register_read_status_cli
19
+ from ara_cli.ara_subcommands.read_user import register as register_read_user_cli
20
+ from ara_cli.ara_subcommands.set_status import register as register_set_status_cli
21
+ from ara_cli.ara_subcommands.set_user import register as register_set_user_cli
22
+ from ara_cli.ara_subcommands.classifier_directory import register as register_classifier_directory_cli
23
+ from ara_cli.ara_subcommands.scan import register as register_scan_cli
24
+ from ara_cli.ara_subcommands.autofix import register as register_autofix_cli
25
+ from ara_cli.ara_subcommands.extract import register as register_extract_cli
26
+ from ara_cli.ara_subcommands.load import register as register_load_cli
53
27
 
28
+ from ara_cli.directory_navigator import DirectoryNavigator
54
29
 
55
- def cli():
56
- parser = action_parser()
57
30
 
58
- # Show examples when help is called
59
- if any(arg in sys.argv for arg in ["-h", "--help"]):
60
- parser.add_examples = True
31
+ def version_callback(value: bool):
32
+ if value:
33
+ typer.echo(f"ara {__version__}")
34
+ raise typer.Exit()
35
+
36
+
37
+ def is_debug_mode_enabled():
38
+ """Check if debug mode is enabled via environment variable."""
39
+ return getenv('ARA_DEBUG', '').lower() in ('1', 'true', 'yes')
40
+
41
+
42
+ def configure_debug_mode(debug: bool, env_debug_mode: bool):
43
+ """Configure debug mode based on arguments and environment."""
44
+ if debug or env_debug_mode:
45
+ error_handler.debug_mode = True
46
+
47
+
48
+ def check_ara_directory_exists():
49
+ """Check if ara directory exists or if we're inside ara directory tree."""
50
+ return DirectoryNavigator.find_ara_directory_root() is not None
51
+
52
+
53
+ def prompt_create_ara_directory():
54
+ """Prompt user to create ara directory and create it if confirmed."""
55
+ # Print the prompt message
56
+ print("No 'ara' directory found. Create one in the current directory? (Y/n)",
57
+ end=" ", flush=True)
58
+
59
+ # Read user input
60
+ try:
61
+ response = input().strip()
62
+ except (EOFError, KeyboardInterrupt):
63
+ typer.echo("\nOperation cancelled.")
64
+ raise typer.Exit(1)
65
+
66
+ if response.lower() in ('y', 'yes', ''):
67
+ current_dir = os.getcwd()
68
+ ara_path = os.path.join(current_dir, 'ara')
69
+
70
+ # Create ara directory structure
71
+ subdirectories = [
72
+ 'businessgoals',
73
+ 'capabilities',
74
+ 'epics',
75
+ 'examples',
76
+ 'features',
77
+ 'keyfeatures',
78
+ 'tasks',
79
+ 'userstories',
80
+ 'vision'
81
+ ]
82
+
83
+ try:
84
+ # Create main ara directory
85
+ os.makedirs(ara_path, exist_ok=True)
86
+
87
+ # Create subdirectories for artefact types
88
+ for subdir in subdirectories:
89
+ os.makedirs(os.path.join(ara_path, subdir), exist_ok=True)
90
+
91
+ # Create .araconfig directory
92
+ araconfig_path = os.path.join(ara_path, '.araconfig')
93
+ os.makedirs(araconfig_path, exist_ok=True)
94
+
95
+ # Create default ara_config.json using ConfigManager
96
+ from ara_cli.ara_config import ConfigManager, ARAconfig
97
+ config_file_path = os.path.join(araconfig_path, 'ara_config.json')
98
+
99
+ # Reset ConfigManager to ensure clean state
100
+ ConfigManager.reset()
101
+
102
+ # Create default config and save it
103
+ default_config = ARAconfig()
104
+ from ara_cli.ara_config import save_data
105
+ save_data(config_file_path, default_config)
61
106
 
62
- parser.add_argument(
63
- "-v", "--version", action="version", version=f"%(prog)s {__version__}"
107
+ typer.echo(f"Created ara directory structure at {ara_path}")
108
+ typer.echo(f"Created default configuration at {config_file_path}")
109
+ return True
110
+
111
+ except OSError as e:
112
+ typer.echo(f"Error creating ara directory: {e}", err=True)
113
+ raise typer.Exit(1)
114
+ except Exception as e:
115
+ typer.echo(f"Error creating configuration file: {e}", err=True)
116
+ raise typer.Exit(1)
117
+ else:
118
+ typer.echo("Ara directory creation cancelled.")
119
+ raise typer.Exit(0)
120
+
121
+
122
+ def requires_ara_directory():
123
+ """Check if ara directory exists and prompt to create if not."""
124
+ if not check_ara_directory_exists():
125
+ return prompt_create_ara_directory()
126
+ return True
127
+
128
+
129
+ def create_app():
130
+ app = typer.Typer(
131
+ help="""The ara cli terminal tool is a management tool for classified ara artefacts.
132
+
133
+ Valid classified artefacts are: businessgoal, vision, capability, keyfeature, feature, epic, userstory, example, feature, task.
134
+
135
+ The default ara directory structure of classified artefact of the ara cli tool is:
136
+ .
137
+ └── ara
138
+ ├── businessgoals
139
+ ├── capabilities
140
+ ├── epics
141
+ ├── examples
142
+ ├── features
143
+ ├── keyfeatures
144
+ ├── tasks
145
+ ├── userstories
146
+ └── vision
147
+
148
+ ara artefact handling examples:
149
+ > create a new artefact for e.g. a feature: ara create feature {feature_name}
150
+ > create a new artefact for e.g. a feature that contributes to an userstory: ara create feature {feature_name} contributes-to userstory {story_name}
151
+ > read an artefact and return the content as terminal output, for eg. of a task: ara read task {task_name}
152
+ > read an artefact and its full chain of contributions to its parents and return
153
+ the content as terminal output, for eg. of a task: ara read task {task_name} --branch
154
+ > delete an artefact for e.g. feature: ara delete feature {feature_name}
155
+ > rename artefact and artefact data directory for e.g. a feature: ara rename feature {initial_feature_name} {new_feature_name}
156
+ > create additional templates for a specific aspect (valid aspects are: customer,
157
+ persona, concept, technology) related to an existing artefact like a feature: ara create feature {feature_name} aspect {aspect_name}
158
+ > list artefact data with .md file extension ara list --data {classifier} {artefact_name} --include-extension .md
159
+ > list artefact data with .md and .json file extensions ara list --data {classifier} {artefact_name} --include-extension .md .json
160
+ > list everything but userstories ara list --exclude-extension .userstory
161
+ > list all existing features: ara list --include-extension .feature
162
+ > list all child artefacts contributing value to a parent artefact: ara list --include-content "Contributes to {name_of_parent_artefact} {ara classifier_of_parent_artefact}"
163
+ > list tasks which contain 'example content' ara list --include-extension .task --include-content "example content"
164
+ > list children artefacts of a userstory ara list --children userstory {name_of_userstory}
165
+ > list parent artefacts of a userstory ara list --branch userstory {name_of_userstory}
166
+ > list parent businessgoal artefact of a userstory ara list --branch userstory {name_of_userstory} --include-extension .businessgoal
167
+ > print any artefact template for e.g. a feature file template in the terminal: ara template feature
168
+
169
+ ara prompt templates examples:
170
+ > get and copy all prompt templates (blueprints, rules, intentions, commands
171
+ in the ara/.araconfig/global-prompt-modules directory: ara fetch-templates
172
+
173
+ ara chat examples:
174
+ > chat with ara and save the default chat.md file in the working directory: ara chat
175
+ > chat with ara and save the default task_chat.md file in the task.data directory: ara prompt chat task {task_name}
176
+
177
+ > initialize a macro prompt for a task: ara prompt init task {task_name}
178
+ > load selected templates in config_prompt_templates.md for the task {task_name}: ara prompt load task {task_name}
179
+ > create and send configured prompt of the task {task_name} to the configured LLM: ara prompt send task {task_name}
180
+ > extract the selected LLM response in task.exploration.md and save to disk: ara prompt extract task {task_name}
181
+ """,
182
+ no_args_is_help=True,
183
+ add_completion=True,
184
+ rich_markup_mode="rich"
64
185
  )
65
186
 
66
- action_mapping = define_action_mapping()
187
+ @app.callback(invoke_without_command=True)
188
+ def main(
189
+ ctx: typer.Context,
190
+ version: Optional[bool] = typer.Option(
191
+ None, "--version", "-v",
192
+ callback=version_callback,
193
+ is_eager=True,
194
+ help="Show version and exit"
195
+ ),
196
+ debug: bool = typer.Option(
197
+ False, "--debug",
198
+ help="Enable debug mode for detailed error output"
199
+ )
200
+ ):
201
+ """The ara cli terminal tool is a management tool for classified ara artefacts."""
202
+ debug_mode = is_debug_mode_enabled()
203
+ configure_debug_mode(debug, debug_mode)
204
+
205
+ # Only show help if no subcommand is invoked
206
+ if ctx.invoked_subcommand is None:
207
+ ctx.get_help()
208
+ ctx.exit()
209
+
210
+ # Check for ara directory before executing any command
211
+ # Skip check for commands that don't require ara directory
212
+ commands_requiring_ara = {
213
+ 'create', 'delete', 'rename', 'list', 'list-tags', 'prompt',
214
+ 'read', 'reconnect', 'read-status', 'read-user', 'set-status',
215
+ 'set-user', 'classifier-directory', 'scan', 'autofix'
216
+ }
67
217
 
68
- argcomplete.autocomplete(parser)
218
+ if ctx.invoked_subcommand in commands_requiring_ara:
219
+ requires_ara_directory()
69
220
 
70
- args = parser.parse_args()
71
- if not hasattr(args, "action") or not args.action:
72
- parser.print_help()
73
- return
74
- action = action_mapping.get(args.action, handle_invalid_action)
75
- action(args)
221
+ # Register all commands
222
+ register_create_cli(app)
223
+ register_delete_cli(app)
224
+ register_rename_cli(app)
225
+ register_list_cli(app)
226
+ register_list_tags_cli(app)
227
+ register_prompt_cli(app)
228
+ register_chat_cli(app)
229
+ register_template_cli(app)
230
+ register_fetch_templates_cli(app)
231
+ register_read_cli(app)
232
+ register_reconnect_cli(app)
233
+ register_read_status_cli(app)
234
+ register_read_user_cli(app)
235
+ register_set_status_cli(app)
236
+ register_set_user_cli(app)
237
+ register_classifier_directory_cli(app)
238
+ register_scan_cli(app)
239
+ register_autofix_cli(app)
240
+ register_extract_cli(app)
241
+ register_load_cli(app)
242
+
243
+ return app
244
+
245
+
246
+ def cli():
247
+ app = create_app()
248
+ try:
249
+ app()
250
+ except KeyboardInterrupt:
251
+ typer.echo("\n[INFO] Operation cancelled by user", err=True)
252
+ raise typer.Exit(130) # Standard exit code for Ctrl+C
253
+ except Exception as e:
254
+ error_handler.handle_error(e, context="cli")
76
255
 
77
256
 
78
257
  if __name__ == "__main__":