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.
- ara_cli/__init__.py +18 -2
- ara_cli/__main__.py +245 -66
- ara_cli/ara_command_action.py +128 -63
- ara_cli/ara_config.py +201 -177
- ara_cli/ara_subcommands/__init__.py +0 -0
- ara_cli/ara_subcommands/autofix.py +26 -0
- ara_cli/ara_subcommands/chat.py +27 -0
- ara_cli/ara_subcommands/classifier_directory.py +16 -0
- ara_cli/ara_subcommands/common.py +100 -0
- ara_cli/ara_subcommands/create.py +75 -0
- ara_cli/ara_subcommands/delete.py +22 -0
- ara_cli/ara_subcommands/extract.py +22 -0
- ara_cli/ara_subcommands/fetch_templates.py +14 -0
- ara_cli/ara_subcommands/list.py +65 -0
- ara_cli/ara_subcommands/list_tags.py +25 -0
- ara_cli/ara_subcommands/load.py +48 -0
- ara_cli/ara_subcommands/prompt.py +136 -0
- ara_cli/ara_subcommands/read.py +47 -0
- ara_cli/ara_subcommands/read_status.py +20 -0
- ara_cli/ara_subcommands/read_user.py +20 -0
- ara_cli/ara_subcommands/reconnect.py +27 -0
- ara_cli/ara_subcommands/rename.py +22 -0
- ara_cli/ara_subcommands/scan.py +14 -0
- ara_cli/ara_subcommands/set_status.py +22 -0
- ara_cli/ara_subcommands/set_user.py +22 -0
- ara_cli/ara_subcommands/template.py +16 -0
- ara_cli/artefact_autofix.py +214 -28
- ara_cli/artefact_creator.py +5 -8
- ara_cli/artefact_deleter.py +2 -4
- ara_cli/artefact_fuzzy_search.py +13 -6
- ara_cli/artefact_lister.py +29 -55
- ara_cli/artefact_models/artefact_data_retrieval.py +23 -0
- ara_cli/artefact_models/artefact_model.py +106 -25
- ara_cli/artefact_models/artefact_templates.py +23 -13
- ara_cli/artefact_models/epic_artefact_model.py +11 -2
- ara_cli/artefact_models/feature_artefact_model.py +56 -1
- ara_cli/artefact_models/userstory_artefact_model.py +15 -3
- ara_cli/artefact_reader.py +4 -5
- ara_cli/artefact_renamer.py +6 -2
- ara_cli/artefact_scan.py +2 -2
- ara_cli/chat.py +594 -219
- ara_cli/chat_agent/__init__.py +0 -0
- ara_cli/chat_agent/agent_communicator.py +62 -0
- ara_cli/chat_agent/agent_process_manager.py +211 -0
- ara_cli/chat_agent/agent_status_manager.py +73 -0
- ara_cli/chat_agent/agent_workspace_manager.py +76 -0
- ara_cli/commands/__init__.py +0 -0
- ara_cli/commands/command.py +7 -0
- ara_cli/commands/extract_command.py +15 -0
- ara_cli/commands/load_command.py +65 -0
- ara_cli/commands/load_image_command.py +34 -0
- ara_cli/commands/read_command.py +117 -0
- ara_cli/completers.py +144 -0
- ara_cli/directory_navigator.py +37 -4
- ara_cli/error_handler.py +134 -0
- ara_cli/file_classifier.py +3 -2
- ara_cli/file_loaders/__init__.py +0 -0
- ara_cli/file_loaders/binary_file_loader.py +33 -0
- ara_cli/file_loaders/document_file_loader.py +34 -0
- ara_cli/file_loaders/document_reader.py +245 -0
- ara_cli/file_loaders/document_readers.py +233 -0
- ara_cli/file_loaders/file_loader.py +50 -0
- ara_cli/file_loaders/file_loaders.py +123 -0
- ara_cli/file_loaders/image_processor.py +89 -0
- ara_cli/file_loaders/markdown_reader.py +75 -0
- ara_cli/file_loaders/text_file_loader.py +187 -0
- ara_cli/global_file_lister.py +51 -0
- ara_cli/prompt_extractor.py +214 -87
- ara_cli/prompt_handler.py +508 -146
- ara_cli/tag_extractor.py +54 -24
- ara_cli/template_loader.py +245 -0
- ara_cli/template_manager.py +14 -4
- ara_cli/templates/prompt-modules/commands/empty.commands.md +2 -12
- ara_cli/templates/prompt-modules/commands/extract_general.commands.md +12 -0
- ara_cli/templates/prompt-modules/commands/extract_markdown.commands.md +11 -0
- ara_cli/templates/prompt-modules/commands/extract_python.commands.md +13 -0
- ara_cli/templates/prompt-modules/commands/feature_add_or_modifiy_specified_behavior.commands.md +36 -0
- ara_cli/templates/prompt-modules/commands/feature_generate_initial_specified_bevahior.commands.md +53 -0
- ara_cli/templates/prompt-modules/commands/prompt_template_tech_stack_transformer.commands.md +95 -0
- ara_cli/templates/prompt-modules/commands/python_bug_fixing_code.commands.md +34 -0
- ara_cli/templates/prompt-modules/commands/python_generate_code.commands.md +27 -0
- ara_cli/templates/prompt-modules/commands/python_refactoring_code.commands.md +39 -0
- ara_cli/templates/prompt-modules/commands/python_step_definitions_generation_and_fixing.commands.md +40 -0
- ara_cli/templates/prompt-modules/commands/python_unittest_generation_and_fixing.commands.md +48 -0
- ara_cli/update_config_prompt.py +7 -1
- ara_cli/version.py +1 -1
- ara_cli-0.1.10.8.dist-info/METADATA +241 -0
- {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/RECORD +104 -59
- tests/test_ara_command_action.py +66 -52
- tests/test_ara_config.py +200 -279
- tests/test_artefact_autofix.py +361 -5
- tests/test_artefact_lister.py +52 -132
- tests/test_artefact_scan.py +1 -1
- tests/test_chat.py +2009 -603
- tests/test_file_classifier.py +23 -0
- tests/test_file_creator.py +3 -5
- tests/test_global_file_lister.py +131 -0
- tests/test_prompt_handler.py +746 -0
- tests/test_tag_extractor.py +19 -13
- tests/test_template_loader.py +192 -0
- tests/test_template_manager.py +5 -4
- ara_cli/ara_command_parser.py +0 -536
- ara_cli/templates/prompt-modules/blueprints/complete_pytest_unittest.blueprint.md +0 -27
- ara_cli/templates/prompt-modules/blueprints/task_todo_list_implement_feature_BDD_way.blueprint.md +0 -30
- ara_cli/templates/prompt-modules/commands/artefact_classification.commands.md +0 -9
- ara_cli/templates/prompt-modules/commands/artefact_extension.commands.md +0 -17
- ara_cli/templates/prompt-modules/commands/artefact_formulation.commands.md +0 -14
- ara_cli/templates/prompt-modules/commands/behave_step_generation.commands.md +0 -102
- ara_cli/templates/prompt-modules/commands/code_generation_complex.commands.md +0 -20
- ara_cli/templates/prompt-modules/commands/code_generation_simple.commands.md +0 -13
- ara_cli/templates/prompt-modules/commands/error_fixing.commands.md +0 -20
- ara_cli/templates/prompt-modules/commands/feature_file_update.commands.md +0 -18
- ara_cli/templates/prompt-modules/commands/feature_formulation.commands.md +0 -43
- ara_cli/templates/prompt-modules/commands/js_code_generation_simple.commands.md +0 -13
- ara_cli/templates/prompt-modules/commands/refactoring.commands.md +0 -15
- ara_cli/templates/prompt-modules/commands/refactoring_analysis.commands.md +0 -9
- ara_cli/templates/prompt-modules/commands/reverse_engineer_feature_file.commands.md +0 -15
- ara_cli/templates/prompt-modules/commands/reverse_engineer_program_flow.commands.md +0 -19
- ara_cli-0.1.9.77.dist-info/METADATA +0 -18
- {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/WHEEL +0 -0
- {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/entry_points.txt +0 -0
- {ara_cli-0.1.9.77.dist-info → ara_cli-0.1.10.8.dist-info}/top_level.txt +0 -0
|
@@ -184,6 +184,10 @@ class Artefact(BaseModel, ABC):
|
|
|
184
184
|
default=[],
|
|
185
185
|
description="Optional list of tags (0-many)",
|
|
186
186
|
)
|
|
187
|
+
author: Optional[str] = Field(
|
|
188
|
+
default="creator_unknown",
|
|
189
|
+
description="Author of the artefact, must be a single entry of the form 'creator_<someone>'."
|
|
190
|
+
)
|
|
187
191
|
title: str = Field(
|
|
188
192
|
...,
|
|
189
193
|
description="Descriptive Artefact title (mandatory)",
|
|
@@ -252,6 +256,17 @@ class Artefact(BaseModel, ABC):
|
|
|
252
256
|
raise ValueError(f"Tag '{tag}' has the form of a status tag. Set `status` field instead of passing it with other tags")
|
|
253
257
|
if tag.startswith("user_"):
|
|
254
258
|
raise ValueError(f"Tag '{tag} has the form of a user tag. Set `users` field instead of passing it with other tags")
|
|
259
|
+
if tag.startswith("creator_"):
|
|
260
|
+
raise ValueError(f"Tag '{tag}' has the form of an author tag. Set `author` field instead of passing it with other tags")
|
|
261
|
+
return v
|
|
262
|
+
|
|
263
|
+
@field_validator('author')
|
|
264
|
+
def validate_author(cls, v):
|
|
265
|
+
if v:
|
|
266
|
+
if not v.startswith("creator_"):
|
|
267
|
+
raise ValueError(f"Author '{v}' must start with 'creator_'.")
|
|
268
|
+
if len(v) <= len("creator_"):
|
|
269
|
+
raise ValueError("Creator name cannot be empty in author tag.")
|
|
255
270
|
return v
|
|
256
271
|
|
|
257
272
|
@field_validator('title')
|
|
@@ -291,32 +306,81 @@ class Artefact(BaseModel, ABC):
|
|
|
291
306
|
tag_line = lines[0]
|
|
292
307
|
if not tag_line.startswith('@'):
|
|
293
308
|
return {}, lines
|
|
309
|
+
|
|
294
310
|
tags = tag_line.split()
|
|
311
|
+
tag_dict = cls._process_tags(tags)
|
|
312
|
+
return tag_dict, lines[1:]
|
|
313
|
+
|
|
314
|
+
@classmethod
|
|
315
|
+
def _process_tags(cls, tags) -> Dict[str, str]:
|
|
316
|
+
"""Process a list of tags and return a dictionary with categorized tags."""
|
|
295
317
|
status = None
|
|
296
318
|
regular_tags = []
|
|
297
319
|
users = []
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
user_prefix_length = len(user_prefix)
|
|
301
|
-
|
|
320
|
+
author = None
|
|
321
|
+
|
|
302
322
|
for tag in tags:
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if tag
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
323
|
+
cls._validate_tag_format(tag)
|
|
324
|
+
|
|
325
|
+
if cls._is_status_tag(tag):
|
|
326
|
+
status = cls._process_status_tag(tag, status)
|
|
327
|
+
elif cls._is_user_tag(tag):
|
|
328
|
+
users.append(cls._extract_user_from_tag(tag))
|
|
329
|
+
elif cls._is_author_tag(tag):
|
|
330
|
+
author = cls._process_author_tag(tag, author)
|
|
331
|
+
else:
|
|
332
|
+
regular_tags.append(tag[1:])
|
|
333
|
+
|
|
334
|
+
return {
|
|
315
335
|
"status": status,
|
|
316
336
|
"users": users,
|
|
317
|
-
"tags": regular_tags
|
|
337
|
+
"tags": regular_tags,
|
|
338
|
+
"author": author
|
|
318
339
|
}
|
|
319
|
-
|
|
340
|
+
|
|
341
|
+
@classmethod
|
|
342
|
+
def _validate_tag_format(cls, tag):
|
|
343
|
+
"""Validate that tag starts with @."""
|
|
344
|
+
if not tag.startswith('@'):
|
|
345
|
+
raise ValueError(f"Tag '{tag}' should start with '@' but started with '{tag[0]}'")
|
|
346
|
+
|
|
347
|
+
@classmethod
|
|
348
|
+
def _is_status_tag(cls, tag) -> bool:
|
|
349
|
+
"""Check if tag is a status tag."""
|
|
350
|
+
status_list = ["@to-do", "@in-progress", "@review", "@done", "@closed"]
|
|
351
|
+
return tag in status_list
|
|
352
|
+
|
|
353
|
+
@classmethod
|
|
354
|
+
def _process_status_tag(cls, tag, current_status):
|
|
355
|
+
"""Process status tag and check for duplicates."""
|
|
356
|
+
if current_status is not None:
|
|
357
|
+
raise ValueError(f"Multiple status tags found: '@{current_status}' and '{tag}'")
|
|
358
|
+
return tag[1:] # Remove @ prefix
|
|
359
|
+
|
|
360
|
+
@classmethod
|
|
361
|
+
def _is_user_tag(cls, tag) -> bool:
|
|
362
|
+
"""Check if tag is a user tag."""
|
|
363
|
+
user_prefix = "@user_"
|
|
364
|
+
return tag.startswith(user_prefix) and len(tag) > len(user_prefix)
|
|
365
|
+
|
|
366
|
+
@classmethod
|
|
367
|
+
def _extract_user_from_tag(cls, tag) -> str:
|
|
368
|
+
"""Extract username from user tag."""
|
|
369
|
+
user_prefix = "@user_"
|
|
370
|
+
return tag[len(user_prefix):]
|
|
371
|
+
|
|
372
|
+
@classmethod
|
|
373
|
+
def _is_author_tag(cls, tag) -> bool:
|
|
374
|
+
"""Check if tag is an author tag."""
|
|
375
|
+
creator_prefix = "@creator_"
|
|
376
|
+
return tag.startswith(creator_prefix) and len(tag) > len(creator_prefix)
|
|
377
|
+
|
|
378
|
+
@classmethod
|
|
379
|
+
def _process_author_tag(cls, tag, current_author):
|
|
380
|
+
"""Process author tag and check for duplicates."""
|
|
381
|
+
if current_author is not None:
|
|
382
|
+
raise ValueError(f"Multiple author tags found: '@{current_author}' and '@{tag[1:]}'")
|
|
383
|
+
return tag[1:]
|
|
320
384
|
|
|
321
385
|
@classmethod
|
|
322
386
|
def _deserialize_title(cls, lines) -> (str, List[str]):
|
|
@@ -346,14 +410,26 @@ class Artefact(BaseModel, ABC):
|
|
|
346
410
|
return contribution, lines
|
|
347
411
|
|
|
348
412
|
@classmethod
|
|
349
|
-
def _deserialize_description(cls, lines) -> (Optional[str], List[str]):
|
|
413
|
+
def _deserialize_description(cls, lines: List[str]) -> (Optional[str], List[str]):
|
|
350
414
|
description_start = cls._description_starts_with()
|
|
415
|
+
start_index = -1
|
|
351
416
|
for i, line in enumerate(lines):
|
|
352
417
|
if line.startswith(description_start):
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
418
|
+
start_index = i
|
|
419
|
+
break
|
|
420
|
+
|
|
421
|
+
if start_index == -1:
|
|
422
|
+
return None, lines
|
|
423
|
+
|
|
424
|
+
first_line_content = lines[start_index][len(description_start):].strip()
|
|
425
|
+
|
|
426
|
+
description_lines = ([first_line_content] if first_line_content else []) + lines[start_index + 1:]
|
|
427
|
+
|
|
428
|
+
description = "\n".join(description_lines)
|
|
429
|
+
|
|
430
|
+
remaining_lines = lines[:start_index]
|
|
431
|
+
|
|
432
|
+
return (description if description else None), remaining_lines
|
|
357
433
|
|
|
358
434
|
@classmethod
|
|
359
435
|
def _parse_common_fields(cls, text: str) -> dict:
|
|
@@ -367,7 +443,7 @@ class Artefact(BaseModel, ABC):
|
|
|
367
443
|
contribution, remaining_lines = cls._deserialize_contribution(remaining_lines)
|
|
368
444
|
description, remaining_lines = cls._deserialize_description(remaining_lines)
|
|
369
445
|
|
|
370
|
-
|
|
446
|
+
fields = {
|
|
371
447
|
'artefact_type': cls._artefact_type(),
|
|
372
448
|
'tags': tags.get('tags', []),
|
|
373
449
|
'users': tags.get('users', []),
|
|
@@ -376,6 +452,9 @@ class Artefact(BaseModel, ABC):
|
|
|
376
452
|
'contribution': contribution,
|
|
377
453
|
'description': description,
|
|
378
454
|
}
|
|
455
|
+
if tags.get("author"):
|
|
456
|
+
fields["author"] = tags.get("author")
|
|
457
|
+
return fields
|
|
379
458
|
|
|
380
459
|
@classmethod
|
|
381
460
|
def deserialize(cls, text: str) -> 'Artefact':
|
|
@@ -407,6 +486,8 @@ class Artefact(BaseModel, ABC):
|
|
|
407
486
|
tags.append(f"@{self.status}")
|
|
408
487
|
for user in self.users:
|
|
409
488
|
tags.append(f"@user_{user}")
|
|
489
|
+
if self.author:
|
|
490
|
+
tags.append(f"@{self.author}")
|
|
410
491
|
for tag in self.tags:
|
|
411
492
|
tags.append(f"@{tag}")
|
|
412
493
|
return ' '.join(tags)
|
|
@@ -430,4 +511,4 @@ class Artefact(BaseModel, ABC):
|
|
|
430
511
|
classifier=classifier,
|
|
431
512
|
rule=rule
|
|
432
513
|
)
|
|
433
|
-
self.contribution = contribution
|
|
514
|
+
self.contribution = contribution
|
|
@@ -29,7 +29,8 @@ def _default_vision(title: str, use_default_contribution: bool) -> VisionArtefac
|
|
|
29
29
|
our_product="<statement of primary differentiation>"
|
|
30
30
|
)
|
|
31
31
|
return VisionArtefact(
|
|
32
|
-
tags=[
|
|
32
|
+
tags=[],
|
|
33
|
+
author="creator_unknown",
|
|
33
34
|
title=title,
|
|
34
35
|
description="<further optional description to understand the vision, markdown capable text formatting>",
|
|
35
36
|
intent=intent,
|
|
@@ -44,7 +45,8 @@ def _default_businessgoal(title: str, use_default_contribution: bool) -> Busines
|
|
|
44
45
|
i_want="<something that helps me to reach my monetary goal>"
|
|
45
46
|
)
|
|
46
47
|
return BusinessgoalArtefact(
|
|
47
|
-
tags=[
|
|
48
|
+
tags=[],
|
|
49
|
+
author="creator_unknown",
|
|
48
50
|
title=title,
|
|
49
51
|
description="<further optional description to understand the businessgoal, markdown capable text formatting>",
|
|
50
52
|
intent=intent,
|
|
@@ -57,7 +59,8 @@ def _default_capability(title: str, use_default_contribution: bool) -> Capabilit
|
|
|
57
59
|
to_be_able_to="<needed capability for stakeholders that are the enablers/relevant for reaching the business goal>"
|
|
58
60
|
)
|
|
59
61
|
return CapabilityArtefact(
|
|
60
|
-
tags=[
|
|
62
|
+
tags=[],
|
|
63
|
+
author="creator_unknown",
|
|
61
64
|
title=title,
|
|
62
65
|
description="<further optional description to understand the capability, markdown capable text formatting>",
|
|
63
66
|
intent=intent,
|
|
@@ -77,7 +80,8 @@ def _default_epic(title: str, use_default_contribution: bool) -> EpicArtefact:
|
|
|
77
80
|
"<rule needed to fulfill the wanted product behavior>"
|
|
78
81
|
]
|
|
79
82
|
return EpicArtefact(
|
|
80
|
-
tags=[
|
|
83
|
+
tags=[],
|
|
84
|
+
author="creator_unknown",
|
|
81
85
|
title=title,
|
|
82
86
|
description="<further optional description to understand the epic, markdown capable text formatting>",
|
|
83
87
|
intent=intent,
|
|
@@ -98,7 +102,8 @@ def _default_userstory(title: str, use_default_contribution: bool) -> UserstoryA
|
|
|
98
102
|
"<rule needed to fulfill the wanted product behavior>"
|
|
99
103
|
]
|
|
100
104
|
return UserstoryArtefact(
|
|
101
|
-
tags=[
|
|
105
|
+
tags=[],
|
|
106
|
+
author="creator_unknown",
|
|
102
107
|
title=title,
|
|
103
108
|
description="<further optional description to understand the userstory, markdown capable text formatting>",
|
|
104
109
|
intent=intent,
|
|
@@ -110,7 +115,8 @@ def _default_userstory(title: str, use_default_contribution: bool) -> UserstoryA
|
|
|
110
115
|
|
|
111
116
|
def _default_example(title: str, use_default_contribution: bool) -> ExampleArtefact:
|
|
112
117
|
return ExampleArtefact(
|
|
113
|
-
tags=[
|
|
118
|
+
tags=[],
|
|
119
|
+
author="creator_unknown",
|
|
114
120
|
title=title,
|
|
115
121
|
description="<further optional description to understand the example, markdown capable text formatting>",
|
|
116
122
|
contribution=default_contribution() if use_default_contribution else None
|
|
@@ -130,7 +136,8 @@ def _default_keyfeature(title: str, use_default_contribution: bool) -> Keyfeatur
|
|
|
130
136
|
THEN some result is to be expected
|
|
131
137
|
AND some other result is to be expected>"""
|
|
132
138
|
return KeyfeatureArtefact(
|
|
133
|
-
tags=[
|
|
139
|
+
tags=[],
|
|
140
|
+
author="creator_unknown",
|
|
134
141
|
title=title,
|
|
135
142
|
description=description,
|
|
136
143
|
intent=intent,
|
|
@@ -148,9 +155,9 @@ def _default_feature(title: str, use_default_contribution: bool) -> FeatureArtef
|
|
|
148
155
|
Scenario(
|
|
149
156
|
title="<descriptive_scenario_title>",
|
|
150
157
|
steps=[
|
|
151
|
-
"Given
|
|
152
|
-
"When
|
|
153
|
-
"Then
|
|
158
|
+
"Given [precondition]",
|
|
159
|
+
"When [action]",
|
|
160
|
+
"Then [expected result]"
|
|
154
161
|
],
|
|
155
162
|
),
|
|
156
163
|
ScenarioOutline(
|
|
@@ -185,7 +192,8 @@ def _default_feature(title: str, use_default_contribution: bool) -> FeatureArtef
|
|
|
185
192
|
description = """<further optional description to understand the feature, no format defined, the example artefact is only a placeholder>"""
|
|
186
193
|
|
|
187
194
|
return FeatureArtefact(
|
|
188
|
-
tags=[
|
|
195
|
+
tags=[],
|
|
196
|
+
author="creator_unknown",
|
|
189
197
|
title=title,
|
|
190
198
|
description=description,
|
|
191
199
|
intent=intent,
|
|
@@ -196,7 +204,8 @@ def _default_feature(title: str, use_default_contribution: bool) -> FeatureArtef
|
|
|
196
204
|
|
|
197
205
|
def _default_task(title: str, use_default_contribution: bool) -> TaskArtefact:
|
|
198
206
|
return TaskArtefact(
|
|
199
|
-
|
|
207
|
+
tags=[],
|
|
208
|
+
status=None,
|
|
200
209
|
title=title,
|
|
201
210
|
description="<further optional description to understand the task, no format defined>",
|
|
202
211
|
contribution=default_contribution() if use_default_contribution else None
|
|
@@ -214,7 +223,8 @@ def _default_issue(title: str, use_default_contribution: bool) -> IssueArtefact:
|
|
|
214
223
|
*or optional free text description*"""
|
|
215
224
|
|
|
216
225
|
return IssueArtefact(
|
|
217
|
-
tags=[
|
|
226
|
+
tags=[],
|
|
227
|
+
author="creator_unknown",
|
|
218
228
|
title=title,
|
|
219
229
|
description=description,
|
|
220
230
|
additional_description=additional_description,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ara_cli.artefact_models.artefact_model import Artefact, ArtefactType, Intent
|
|
2
|
-
from pydantic import Field, field_validator
|
|
2
|
+
from pydantic import Field, field_validator, model_validator
|
|
3
3
|
from typing import List, Tuple, Optional
|
|
4
4
|
|
|
5
5
|
|
|
@@ -91,6 +91,15 @@ class EpicArtefact(Artefact):
|
|
|
91
91
|
description="Rules the epic defines. It is recommended to create rules to clarify the desired outcome"
|
|
92
92
|
)
|
|
93
93
|
|
|
94
|
+
@model_validator(mode='after')
|
|
95
|
+
def check_for_misplaced_rules(self) -> 'EpicArtefact':
|
|
96
|
+
if self.description:
|
|
97
|
+
desc_lines = self.description.split('\n')
|
|
98
|
+
for line in desc_lines:
|
|
99
|
+
if line.strip().startswith("Rule:"):
|
|
100
|
+
raise ValueError("Found 'Rule:' inside description. Rules must be defined before the 'Description:' section.")
|
|
101
|
+
return self
|
|
102
|
+
|
|
94
103
|
@field_validator('artefact_type')
|
|
95
104
|
def validate_artefact_type(cls, v):
|
|
96
105
|
if v != ArtefactType.epic:
|
|
@@ -166,4 +175,4 @@ class EpicArtefact(Artefact):
|
|
|
166
175
|
lines.append("")
|
|
167
176
|
lines.append(description)
|
|
168
177
|
lines.append("")
|
|
169
|
-
return "\n".join(lines)
|
|
178
|
+
return "\n".join(lines)
|
|
@@ -148,6 +148,30 @@ class Scenario(BaseModel):
|
|
|
148
148
|
raise ValueError("steps list must not be empty")
|
|
149
149
|
return steps
|
|
150
150
|
|
|
151
|
+
@model_validator(mode='after')
|
|
152
|
+
def check_no_placeholders(cls, values: 'Scenario') -> 'Scenario':
|
|
153
|
+
"""Ensure regular scenarios don't contain placeholders that should be in scenario outlines."""
|
|
154
|
+
placeholders = set()
|
|
155
|
+
for step in values.steps:
|
|
156
|
+
# Skip validation if step contains docstring placeholders (during parsing)
|
|
157
|
+
if '__DOCSTRING_PLACEHOLDER_' in step:
|
|
158
|
+
continue
|
|
159
|
+
|
|
160
|
+
# Skip validation if step contains docstring markers (after reinjection)
|
|
161
|
+
if '"""' in step:
|
|
162
|
+
continue
|
|
163
|
+
|
|
164
|
+
found = re.findall(r'<([^>]+)>', step)
|
|
165
|
+
placeholders.update(found)
|
|
166
|
+
|
|
167
|
+
if placeholders:
|
|
168
|
+
placeholder_list = ', '.join(f"<{p}>" for p in sorted(placeholders))
|
|
169
|
+
raise ValueError(
|
|
170
|
+
f"Scenario Contains Placeholders ({placeholder_list}) but is not a Scenario Outline. "
|
|
171
|
+
f"Use 'Scenario Outline:' instead of 'Scenario:' and provide an Examples table."
|
|
172
|
+
)
|
|
173
|
+
return values
|
|
174
|
+
|
|
151
175
|
@classmethod
|
|
152
176
|
def from_lines(cls, lines: List[str], start_idx: int) -> Tuple['Scenario', int]:
|
|
153
177
|
"""Parse a Scenario from a list of lines starting at start_idx."""
|
|
@@ -277,6 +301,37 @@ class FeatureArtefact(Artefact):
|
|
|
277
301
|
f"FeatureArtefact must have artefact_type of '{ArtefactType.feature}', not '{v}'")
|
|
278
302
|
return v
|
|
279
303
|
|
|
304
|
+
@classmethod
|
|
305
|
+
def _deserialize_description(cls, lines: List[str]) -> (Optional[str], List[str]):
|
|
306
|
+
description_start = cls._description_starts_with()
|
|
307
|
+
scenario_markers = ["Scenario:", "Scenario Outline:"]
|
|
308
|
+
|
|
309
|
+
start_index = -1
|
|
310
|
+
for i, line in enumerate(lines):
|
|
311
|
+
if line.startswith(description_start):
|
|
312
|
+
start_index = i
|
|
313
|
+
break
|
|
314
|
+
|
|
315
|
+
if start_index == -1:
|
|
316
|
+
return None, lines
|
|
317
|
+
|
|
318
|
+
end_index = len(lines)
|
|
319
|
+
for i in range(start_index + 1, len(lines)):
|
|
320
|
+
if any(lines[i].startswith(marker) for marker in scenario_markers):
|
|
321
|
+
end_index = i
|
|
322
|
+
break
|
|
323
|
+
|
|
324
|
+
first_line_content = lines[start_index][len(description_start):].strip()
|
|
325
|
+
|
|
326
|
+
description_lines_list = [first_line_content] if first_line_content else []
|
|
327
|
+
description_lines_list.extend(lines[start_index+1:end_index])
|
|
328
|
+
|
|
329
|
+
description = "\n".join(description_lines_list).strip() or None
|
|
330
|
+
|
|
331
|
+
remaining_lines = lines[:start_index] + lines[end_index:]
|
|
332
|
+
|
|
333
|
+
return description, remaining_lines
|
|
334
|
+
|
|
280
335
|
@classmethod
|
|
281
336
|
def _title_prefix(cls) -> str:
|
|
282
337
|
return "Feature:"
|
|
@@ -494,4 +549,4 @@ class FeatureArtefact(Artefact):
|
|
|
494
549
|
# or the placeholder is at the end of a line (e.g., "Then I see... __PLACEHOLDER__").
|
|
495
550
|
step = step.replace(key, value)
|
|
496
551
|
rehydrated_steps.append(step)
|
|
497
|
-
return rehydrated_steps
|
|
552
|
+
return rehydrated_steps
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from ara_cli.artefact_models.artefact_model import Artefact, ArtefactType, Intent
|
|
2
|
-
from pydantic import Field, field_validator
|
|
2
|
+
from pydantic import Field, field_validator, model_validator
|
|
3
3
|
from typing import List, Tuple
|
|
4
4
|
|
|
5
5
|
|
|
@@ -92,6 +92,18 @@ class UserstoryArtefact(Artefact):
|
|
|
92
92
|
default_factory=list,
|
|
93
93
|
description="Rules the userstory defines. It is recommended to create rules to clarify the desired outcome")
|
|
94
94
|
|
|
95
|
+
@model_validator(mode='after')
|
|
96
|
+
def check_for_misplaced_content(self) -> 'UserstoryArtefact':
|
|
97
|
+
if self.description:
|
|
98
|
+
desc_lines = self.description.split('\n')
|
|
99
|
+
for line in desc_lines:
|
|
100
|
+
stripped_line = line.strip()
|
|
101
|
+
if stripped_line.startswith("Rule:"):
|
|
102
|
+
raise ValueError("Found 'Rule:' inside description. Rules must be defined before the 'Description:' section.")
|
|
103
|
+
if stripped_line.startswith("Estimate:"):
|
|
104
|
+
raise ValueError("Found 'Estimate:' inside description. Estimate must be defined before the 'Description:' section.")
|
|
105
|
+
return self
|
|
106
|
+
|
|
95
107
|
@field_validator('artefact_type')
|
|
96
108
|
def validate_artefact_type(cls, v):
|
|
97
109
|
if v != ArtefactType.userstory:
|
|
@@ -171,7 +183,7 @@ class UserstoryArtefact(Artefact):
|
|
|
171
183
|
rules = self._serialize_rules()
|
|
172
184
|
|
|
173
185
|
lines = []
|
|
174
|
-
if self.tags
|
|
186
|
+
if tags: # Changed from self.tags to tags to include all tag types
|
|
175
187
|
lines.append(tags)
|
|
176
188
|
lines.append(title)
|
|
177
189
|
lines.append("")
|
|
@@ -188,4 +200,4 @@ class UserstoryArtefact(Artefact):
|
|
|
188
200
|
lines.append(description)
|
|
189
201
|
lines.append("")
|
|
190
202
|
|
|
191
|
-
return '\n'.join(lines)
|
|
203
|
+
return '\n'.join(lines)
|
ara_cli/artefact_reader.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from . import error_handler
|
|
1
2
|
from ara_cli.classifier import Classifier
|
|
2
3
|
from ara_cli.file_classifier import FileClassifier
|
|
3
4
|
from ara_cli.artefact_models.artefact_model import Artefact
|
|
@@ -12,8 +13,7 @@ class ArtefactReader:
|
|
|
12
13
|
@staticmethod
|
|
13
14
|
def read_artefact_data(artefact_name, classifier, classified_file_info = None) -> tuple[str, dict[str, str]]:
|
|
14
15
|
if not Classifier.is_valid_classifier(classifier):
|
|
15
|
-
|
|
16
|
-
return None, None
|
|
16
|
+
raise ValueError("Invalid classifier provided. Please provide a valid classifier.")
|
|
17
17
|
|
|
18
18
|
if not classified_file_info:
|
|
19
19
|
file_classifier = FileClassifier(os)
|
|
@@ -74,7 +74,6 @@ class ArtefactReader:
|
|
|
74
74
|
|
|
75
75
|
@staticmethod
|
|
76
76
|
def read_artefacts(classified_artefacts=None, file_system=os, tags=None) -> Dict[str, List[Artefact]]:
|
|
77
|
-
from ara_cli.artefact_models.artefact_load import artefact_from_content
|
|
78
77
|
|
|
79
78
|
if classified_artefacts is None:
|
|
80
79
|
file_classifier = FileClassifier(file_system)
|
|
@@ -89,7 +88,7 @@ class ArtefactReader:
|
|
|
89
88
|
artefact = ArtefactReader.read_artefact(title, artefact_type, classified_artefacts)
|
|
90
89
|
artefacts[artefact_type].append(artefact)
|
|
91
90
|
except Exception as e:
|
|
92
|
-
|
|
91
|
+
error_handler.report_error(e, f"reading {artefact_type} '{title}'")
|
|
93
92
|
continue
|
|
94
93
|
return artefacts
|
|
95
94
|
|
|
@@ -143,7 +142,7 @@ class ArtefactReader:
|
|
|
143
142
|
ArtefactReader._ensure_classifier_key(classifier, artefacts_by_classifier)
|
|
144
143
|
|
|
145
144
|
artefact = ArtefactReader._find_artefact_by_name(
|
|
146
|
-
artefact_name,
|
|
145
|
+
artefact_name,
|
|
147
146
|
classified_artefacts.get(classifier, [])
|
|
148
147
|
)
|
|
149
148
|
|
ara_cli/artefact_renamer.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import os
|
|
2
1
|
from functools import lru_cache
|
|
3
2
|
from ara_cli.classifier import Classifier
|
|
4
3
|
from ara_cli.artefact_link_updater import ArtefactLinkUpdater
|
|
5
4
|
from ara_cli.template_manager import DirectoryNavigator
|
|
5
|
+
import os
|
|
6
6
|
import re
|
|
7
|
+
import warnings
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class ArtefactRenamer:
|
|
@@ -22,6 +23,8 @@ class ArtefactRenamer:
|
|
|
22
23
|
return re.compile(pattern)
|
|
23
24
|
|
|
24
25
|
def rename(self, old_name, new_name, classifier):
|
|
26
|
+
import shutil
|
|
27
|
+
|
|
25
28
|
original_directory = self.navigate_to_target()
|
|
26
29
|
|
|
27
30
|
if not new_name:
|
|
@@ -47,7 +50,8 @@ class ArtefactRenamer:
|
|
|
47
50
|
if self.file_system.path.exists(new_file_path):
|
|
48
51
|
raise FileExistsError(f"The new file name {new_file_path} already exists.")
|
|
49
52
|
if self.file_system.path.exists(new_dir_path):
|
|
50
|
-
|
|
53
|
+
warnings.warn(f"The new directory name {new_dir_path} already exists. It will be replaced by the artefact's data directory or removed entirely.", UserWarning)
|
|
54
|
+
shutil.rmtree(new_dir_path)
|
|
51
55
|
|
|
52
56
|
# Perform the renaming of the file and directory
|
|
53
57
|
self.file_system.rename(old_file_path, new_file_path)
|
ara_cli/artefact_scan.py
CHANGED
|
@@ -25,10 +25,10 @@ def is_rule_valid(contribution, classified_artefact_info) -> bool:
|
|
|
25
25
|
if not rule:
|
|
26
26
|
return True
|
|
27
27
|
parent = ArtefactReader.read_artefact(contribution.artefact_name, contribution.classifier)
|
|
28
|
-
if not parent
|
|
28
|
+
if not parent:
|
|
29
29
|
return True
|
|
30
30
|
rules = parent.rules
|
|
31
|
-
if rule not in rules:
|
|
31
|
+
if not rules or rule not in rules:
|
|
32
32
|
return False
|
|
33
33
|
return True
|
|
34
34
|
|