mcp-ticketer 0.1.26__py3-none-any.whl → 0.1.28__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 mcp-ticketer might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  """Version information for mcp-ticketer package."""
2
2
 
3
- __version__ = "0.1.26"
3
+ __version__ = "0.1.28"
4
4
  __version_info__ = tuple(int(part) for part in __version__.split("."))
5
5
 
6
6
  # Package metadata
@@ -235,6 +235,64 @@ class AITrackdownAdapter(BaseAdapter[Task]):
235
235
 
236
236
  return ticket
237
237
 
238
+ async def create_epic(self, title: str, description: str = None, **kwargs) -> Epic:
239
+ """Create a new epic.
240
+
241
+ Args:
242
+ title: Epic title
243
+ description: Epic description
244
+ **kwargs: Additional epic properties
245
+
246
+ Returns:
247
+ Created Epic instance
248
+ """
249
+ epic = Epic(
250
+ title=title,
251
+ description=description,
252
+ **kwargs
253
+ )
254
+ return await self.create(epic)
255
+
256
+ async def create_issue(self, title: str, parent_epic: str = None, description: str = None, **kwargs) -> Task:
257
+ """Create a new issue.
258
+
259
+ Args:
260
+ title: Issue title
261
+ parent_epic: Parent epic ID
262
+ description: Issue description
263
+ **kwargs: Additional issue properties
264
+
265
+ Returns:
266
+ Created Task instance (representing an issue)
267
+ """
268
+ task = Task(
269
+ title=title,
270
+ description=description,
271
+ parent_epic=parent_epic,
272
+ **kwargs
273
+ )
274
+ return await self.create(task)
275
+
276
+ async def create_task(self, title: str, parent_id: str, description: str = None, **kwargs) -> Task:
277
+ """Create a new task under an issue.
278
+
279
+ Args:
280
+ title: Task title
281
+ parent_id: Parent issue ID
282
+ description: Task description
283
+ **kwargs: Additional task properties
284
+
285
+ Returns:
286
+ Created Task instance
287
+ """
288
+ task = Task(
289
+ title=title,
290
+ description=description,
291
+ parent_issue=parent_id,
292
+ **kwargs
293
+ )
294
+ return await self.create(task)
295
+
238
296
  async def read(self, ticket_id: str) -> Optional[Union[Task, Epic]]:
239
297
  """Read a task by ID."""
240
298
  if self.tracker:
@@ -8,7 +8,7 @@ import builtins
8
8
  import json
9
9
  import logging
10
10
  from pathlib import Path
11
- from typing import Any, Optional
11
+ from typing import Any, Optional, Union
12
12
 
13
13
  from ..core.adapter import BaseAdapter
14
14
  from ..core.models import Comment, Epic, SearchQuery, Task, TicketState
@@ -153,7 +153,7 @@ class HybridAdapter(BaseAdapter):
153
153
 
154
154
  return f"hybrid-{uuid.uuid4().hex[:12]}"
155
155
 
156
- async def create(self, ticket: Task | Epic) -> Task | Epic:
156
+ async def create(self, ticket: Union[Task, Epic]) -> Union[Task, Epic]:
157
157
  """Create ticket in all configured adapters.
158
158
 
159
159
  Args:
@@ -208,7 +208,7 @@ class HybridAdapter(BaseAdapter):
208
208
  return primary_ticket
209
209
 
210
210
  def _add_cross_references(
211
- self, ticket: Task | Epic, results: list[tuple[str, Task | Epic]]
211
+ self, ticket: Union[Task, Epic], results: list[tuple[str, Union[Task, Epic]]]
212
212
  ) -> None:
213
213
  """Add cross-references to ticket description.
214
214
 
@@ -226,7 +226,7 @@ class HybridAdapter(BaseAdapter):
226
226
  else:
227
227
  ticket.description = cross_refs.strip()
228
228
 
229
- async def read(self, ticket_id: str) -> Optional[Task | Epic]:
229
+ async def read(self, ticket_id: str) -> Optional[Union[Task, Epic]]:
230
230
  """Read ticket from primary adapter.
231
231
 
232
232
  Args:
@@ -255,7 +255,7 @@ class HybridAdapter(BaseAdapter):
255
255
 
256
256
  async def update(
257
257
  self, ticket_id: str, updates: dict[str, Any]
258
- ) -> Optional[Task | Epic]:
258
+ ) -> Optional[Union[Task, Epic]]:
259
259
  """Update ticket across all adapters.
260
260
 
261
261
  Args:
@@ -360,7 +360,7 @@ class HybridAdapter(BaseAdapter):
360
360
 
361
361
  async def list(
362
362
  self, limit: int = 10, offset: int = 0, filters: Optional[dict[str, Any]] = None
363
- ) -> list[Task | Epic]:
363
+ ) -> list[Union[Task, Epic]]:
364
364
  """List tickets from primary adapter.
365
365
 
366
366
  Args:
@@ -375,7 +375,7 @@ class HybridAdapter(BaseAdapter):
375
375
  primary = self.adapters[self.primary_adapter_name]
376
376
  return await primary.list(limit, offset, filters)
377
377
 
378
- async def search(self, query: SearchQuery) -> builtins.list[Task | Epic]:
378
+ async def search(self, query: SearchQuery) -> builtins.list[Union[Task, Epic]]:
379
379
  """Search tickets in primary adapter.
380
380
 
381
381
  Args:
@@ -390,7 +390,7 @@ class HybridAdapter(BaseAdapter):
390
390
 
391
391
  async def transition_state(
392
392
  self, ticket_id: str, target_state: TicketState
393
- ) -> Optional[Task | Epic]:
393
+ ) -> Optional[Union[Task, Epic]]:
394
394
  """Transition ticket state across all adapters.
395
395
 
396
396
  Args:
@@ -973,6 +973,66 @@ class LinearAdapter(BaseAdapter[Task]):
973
973
  created_issue = result["issueCreate"]["issue"]
974
974
  return self._task_from_linear_issue(created_issue)
975
975
 
976
+ async def create_epic(self, title: str, description: str = None, **kwargs) -> Task:
977
+ """Create a new epic (Linear project).
978
+
979
+ Args:
980
+ title: Epic title
981
+ description: Epic description
982
+ **kwargs: Additional epic properties
983
+
984
+ Returns:
985
+ Created Task instance representing the epic
986
+ """
987
+ # In Linear, epics are represented as issues with special labels/properties
988
+ task = Task(
989
+ title=title,
990
+ description=description,
991
+ tags=kwargs.get('tags', []) + ['epic'], # Add epic tag
992
+ **{k: v for k, v in kwargs.items() if k != 'tags'}
993
+ )
994
+ return await self.create(task)
995
+
996
+ async def create_issue(self, title: str, parent_epic: str = None, description: str = None, **kwargs) -> Task:
997
+ """Create a new issue.
998
+
999
+ Args:
1000
+ title: Issue title
1001
+ parent_epic: Parent epic ID
1002
+ description: Issue description
1003
+ **kwargs: Additional issue properties
1004
+
1005
+ Returns:
1006
+ Created Task instance representing the issue
1007
+ """
1008
+ task = Task(
1009
+ title=title,
1010
+ description=description,
1011
+ parent_epic=parent_epic,
1012
+ **kwargs
1013
+ )
1014
+ return await self.create(task)
1015
+
1016
+ async def create_task(self, title: str, parent_id: str, description: str = None, **kwargs) -> Task:
1017
+ """Create a new task under an issue.
1018
+
1019
+ Args:
1020
+ title: Task title
1021
+ parent_id: Parent issue ID
1022
+ description: Task description
1023
+ **kwargs: Additional task properties
1024
+
1025
+ Returns:
1026
+ Created Task instance
1027
+ """
1028
+ task = Task(
1029
+ title=title,
1030
+ description=description,
1031
+ parent_issue=parent_id,
1032
+ **kwargs
1033
+ )
1034
+ return await self.create(task)
1035
+
976
1036
  async def read(self, ticket_id: str) -> Optional[Task]:
977
1037
  """Read a Linear issue by identifier with full details."""
978
1038
  # Validate credentials before attempting operation
mcp_ticketer/cli/main.py CHANGED
@@ -16,6 +16,11 @@ from ..__version__ import __version__
16
16
  from ..core import AdapterRegistry, Priority, TicketState
17
17
  from ..core.models import SearchQuery
18
18
  from ..queue import Queue, QueueStatus, WorkerManager
19
+ from ..queue.health_monitor import QueueHealthMonitor, HealthStatus
20
+ from ..queue.ticket_registry import TicketRegistry
21
+
22
+ # Import adapters module to trigger registration
23
+ import mcp_ticketer.adapters # noqa: F401
19
24
  from .configure import configure_wizard, set_adapter_config, show_current_config
20
25
  from .discover import app as discover_app
21
26
  from .migrate_config import migrate_config_command
@@ -791,6 +796,76 @@ def status_command():
791
796
  )
792
797
 
793
798
 
799
+ @app.command()
800
+ def health(
801
+ auto_repair: bool = typer.Option(False, "--auto-repair", help="Attempt automatic repair of issues"),
802
+ verbose: bool = typer.Option(False, "--verbose", "-v", help="Show detailed health information")
803
+ ) -> None:
804
+ """Check queue system health and detect issues immediately."""
805
+
806
+ health_monitor = QueueHealthMonitor()
807
+ health = health_monitor.check_health()
808
+
809
+ # Display overall status
810
+ status_color = {
811
+ HealthStatus.HEALTHY: "green",
812
+ HealthStatus.WARNING: "yellow",
813
+ HealthStatus.CRITICAL: "red",
814
+ HealthStatus.FAILED: "red"
815
+ }
816
+
817
+ status_icon = {
818
+ HealthStatus.HEALTHY: "✓",
819
+ HealthStatus.WARNING: "⚠️",
820
+ HealthStatus.CRITICAL: "🚨",
821
+ HealthStatus.FAILED: "❌"
822
+ }
823
+
824
+ color = status_color.get(health["status"], "white")
825
+ icon = status_icon.get(health["status"], "?")
826
+
827
+ console.print(f"[{color}]{icon} Queue Health: {health['status'].upper()}[/{color}]")
828
+ console.print(f"Last checked: {health['timestamp']}")
829
+
830
+ # Display alerts
831
+ if health["alerts"]:
832
+ console.print("\n[bold]Issues Found:[/bold]")
833
+ for alert in health["alerts"]:
834
+ alert_color = status_color.get(alert["level"], "white")
835
+ console.print(f"[{alert_color}] • {alert['message']}[/{alert_color}]")
836
+
837
+ if verbose and alert.get("details"):
838
+ for key, value in alert["details"].items():
839
+ console.print(f" {key}: {value}")
840
+ else:
841
+ console.print("\n[green]✓ No issues detected[/green]")
842
+
843
+ # Auto-repair if requested
844
+ if auto_repair and health["status"] in [HealthStatus.CRITICAL, HealthStatus.WARNING]:
845
+ console.print("\n[yellow]Attempting automatic repair...[/yellow]")
846
+ repair_result = health_monitor.auto_repair()
847
+
848
+ if repair_result["actions_taken"]:
849
+ console.print("[green]Repair actions taken:[/green]")
850
+ for action in repair_result["actions_taken"]:
851
+ console.print(f"[green] ✓ {action}[/green]")
852
+
853
+ # Re-check health
854
+ console.print("\n[yellow]Re-checking health after repair...[/yellow]")
855
+ new_health = health_monitor.check_health()
856
+ new_color = status_color.get(new_health["status"], "white")
857
+ new_icon = status_icon.get(new_health["status"], "?")
858
+ console.print(f"[{new_color}]{new_icon} Updated Health: {new_health['status'].upper()}[/{new_color}]")
859
+ else:
860
+ console.print("[yellow]No repair actions available[/yellow]")
861
+
862
+ # Exit with appropriate code
863
+ if health["status"] == HealthStatus.CRITICAL:
864
+ raise typer.Exit(1)
865
+ elif health["status"] == HealthStatus.WARNING:
866
+ raise typer.Exit(2)
867
+
868
+
794
869
  @app.command()
795
870
  def create(
796
871
  title: str = typer.Argument(..., help="Ticket title"),
@@ -810,7 +885,46 @@ def create(
810
885
  None, "--adapter", help="Override default adapter"
811
886
  ),
812
887
  ) -> None:
813
- """Create a new ticket."""
888
+ """Create a new ticket with comprehensive health checks."""
889
+
890
+ # IMMEDIATE HEALTH CHECK - Critical for reliability
891
+ health_monitor = QueueHealthMonitor()
892
+ health = health_monitor.check_health()
893
+
894
+ # Display health status
895
+ if health["status"] == HealthStatus.CRITICAL:
896
+ console.print("[red]🚨 CRITICAL: Queue system has serious issues![/red]")
897
+ for alert in health["alerts"]:
898
+ if alert["level"] == "critical":
899
+ console.print(f"[red] • {alert['message']}[/red]")
900
+
901
+ # Attempt auto-repair
902
+ console.print("[yellow]Attempting automatic repair...[/yellow]")
903
+ repair_result = health_monitor.auto_repair()
904
+
905
+ if repair_result["actions_taken"]:
906
+ for action in repair_result["actions_taken"]:
907
+ console.print(f"[yellow] ✓ {action}[/yellow]")
908
+
909
+ # Re-check health after repair
910
+ health = health_monitor.check_health()
911
+ if health["status"] == HealthStatus.CRITICAL:
912
+ console.print("[red]❌ Auto-repair failed. Manual intervention required.[/red]")
913
+ console.print("[red]Cannot safely create ticket. Please check system status.[/red]")
914
+ raise typer.Exit(1)
915
+ else:
916
+ console.print("[green]✓ Auto-repair successful. Proceeding with ticket creation.[/green]")
917
+ else:
918
+ console.print("[red]❌ No repair actions available. Manual intervention required.[/red]")
919
+ raise typer.Exit(1)
920
+
921
+ elif health["status"] == HealthStatus.WARNING:
922
+ console.print("[yellow]⚠️ Warning: Queue system has minor issues[/yellow]")
923
+ for alert in health["alerts"]:
924
+ if alert["level"] == "warning":
925
+ console.print(f"[yellow] • {alert['message']}[/yellow]")
926
+ console.print("[yellow]Proceeding with ticket creation...[/yellow]")
927
+
814
928
  # Get the adapter name
815
929
  config = load_config()
816
930
  adapter_name = (
@@ -832,16 +946,44 @@ def create(
832
946
  ticket_data=task_data, adapter=adapter_name, operation="create"
833
947
  )
834
948
 
949
+ # Register in ticket registry for tracking
950
+ registry = TicketRegistry()
951
+ registry.register_ticket_operation(queue_id, adapter_name, "create", title, task_data)
952
+
835
953
  console.print(f"[green]✓[/green] Queued ticket creation: {queue_id}")
836
954
  console.print(f" Title: {title}")
837
955
  console.print(f" Priority: {priority}")
838
- console.print("[dim]Use 'mcp-ticketer status {queue_id}' to check progress[/dim]")
956
+ console.print(f" Adapter: {adapter_name}")
957
+ console.print("[dim]Use 'mcp-ticketer check {queue_id}' to check progress[/dim]")
839
958
 
840
- # Start worker if needed
959
+ # Start worker if needed with immediate feedback
841
960
  manager = WorkerManager()
842
- if manager.start_if_needed():
961
+ worker_started = manager.start_if_needed()
962
+
963
+ if worker_started:
843
964
  console.print("[dim]Worker started to process request[/dim]")
844
965
 
966
+ # Give immediate feedback on processing
967
+ import time
968
+ time.sleep(1) # Brief pause to let worker start
969
+
970
+ # Check if item is being processed
971
+ item = queue.get_item(queue_id)
972
+ if item and item.status == QueueStatus.PROCESSING:
973
+ console.print("[green]✓ Item is being processed by worker[/green]")
974
+ elif item and item.status == QueueStatus.PENDING:
975
+ console.print("[yellow]⏳ Item is queued for processing[/yellow]")
976
+ else:
977
+ console.print("[red]⚠️ Item status unclear - check with 'mcp-ticketer check {queue_id}'[/red]")
978
+ else:
979
+ # Worker didn't start - this is a problem
980
+ pending_count = queue.get_pending_count()
981
+ if pending_count > 1: # More than just this item
982
+ console.print(f"[red]❌ Worker failed to start with {pending_count} pending items![/red]")
983
+ console.print("[red]This is a critical issue. Try 'mcp-ticketer queue worker start' manually.[/red]")
984
+ else:
985
+ console.print("[yellow]Worker not started (no other pending items)[/yellow]")
986
+
845
987
 
846
988
  @app.command("list")
847
989
  def list_tickets(
@@ -9,7 +9,7 @@ from pathlib import Path
9
9
  from typing import Any, Optional, Union
10
10
 
11
11
  import yaml
12
- from pydantic import BaseModel, Field, root_validator, validator
12
+ from pydantic import BaseModel, Field, field_validator, model_validator
13
13
 
14
14
  logger = logging.getLogger(__name__)
15
15
 
@@ -45,24 +45,27 @@ class GitHubConfig(BaseAdapterConfig):
45
45
  use_projects_v2: bool = False
46
46
  custom_priority_scheme: Optional[dict[str, list[str]]] = None
47
47
 
48
- @validator("token", pre=True, always=True)
49
- def validate_token(self, v):
48
+ @field_validator("token", mode="before")
49
+ @classmethod
50
+ def validate_token(cls, v):
50
51
  if not v:
51
52
  v = os.getenv("GITHUB_TOKEN")
52
53
  if not v:
53
54
  raise ValueError("GitHub token is required")
54
55
  return v
55
56
 
56
- @validator("owner", pre=True, always=True)
57
- def validate_owner(self, v):
57
+ @field_validator("owner", mode="before")
58
+ @classmethod
59
+ def validate_owner(cls, v):
58
60
  if not v:
59
61
  v = os.getenv("GITHUB_OWNER")
60
62
  if not v:
61
63
  raise ValueError("GitHub owner is required")
62
64
  return v
63
65
 
64
- @validator("repo", pre=True, always=True)
65
- def validate_repo(self, v):
66
+ @field_validator("repo", mode="before")
67
+ @classmethod
68
+ def validate_repo(cls, v):
66
69
  if not v:
67
70
  v = os.getenv("GITHUB_REPO")
68
71
  if not v:
@@ -81,24 +84,27 @@ class JiraConfig(BaseAdapterConfig):
81
84
  cloud: bool = True
82
85
  verify_ssl: bool = True
83
86
 
84
- @validator("server", pre=True, always=True)
85
- def validate_server(self, v):
87
+ @field_validator("server", mode="before")
88
+ @classmethod
89
+ def validate_server(cls, v):
86
90
  if not v:
87
91
  v = os.getenv("JIRA_SERVER")
88
92
  if not v:
89
93
  raise ValueError("JIRA server URL is required")
90
94
  return v.rstrip("/")
91
95
 
92
- @validator("email", pre=True, always=True)
93
- def validate_email(self, v):
96
+ @field_validator("email", mode="before")
97
+ @classmethod
98
+ def validate_email(cls, v):
94
99
  if not v:
95
100
  v = os.getenv("JIRA_EMAIL")
96
101
  if not v:
97
102
  raise ValueError("JIRA email is required")
98
103
  return v
99
104
 
100
- @validator("api_token", pre=True, always=True)
101
- def validate_api_token(self, v):
105
+ @field_validator("api_token", mode="before")
106
+ @classmethod
107
+ def validate_api_token(cls, v):
102
108
  if not v:
103
109
  v = os.getenv("JIRA_API_TOKEN")
104
110
  if not v:
@@ -115,8 +121,9 @@ class LinearConfig(BaseAdapterConfig):
115
121
  team_key: str
116
122
  api_url: str = "https://api.linear.app/graphql"
117
123
 
118
- @validator("api_key", pre=True, always=True)
119
- def validate_api_key(self, v):
124
+ @field_validator("api_key", mode="before")
125
+ @classmethod
126
+ def validate_api_key(cls, v):
120
127
  if not v:
121
128
  v = os.getenv("LINEAR_API_KEY")
122
129
  if not v:
@@ -163,23 +170,23 @@ class AppConfig(BaseModel):
163
170
  cache_ttl: int = 300 # Cache TTL in seconds
164
171
  default_adapter: Optional[str] = None
165
172
 
166
- @root_validator(skip_on_failure=True)
167
- def validate_adapters(self, values):
173
+ @model_validator(mode="after")
174
+ def validate_adapters(self):
168
175
  """Validate adapter configurations."""
169
- adapters = values.get("adapters", {})
176
+ adapters = self.adapters
170
177
 
171
178
  if not adapters:
172
179
  logger.warning("No adapters configured")
173
- return values
180
+ return self
174
181
 
175
182
  # Validate default adapter
176
- default_adapter = values.get("default_adapter")
183
+ default_adapter = self.default_adapter
177
184
  if default_adapter and default_adapter not in adapters:
178
185
  raise ValueError(
179
186
  f"Default adapter '{default_adapter}' not found in adapters"
180
187
  )
181
188
 
182
- return values
189
+ return self
183
190
 
184
191
  def get_adapter_config(self, adapter_name: str) -> Optional[BaseAdapterConfig]:
185
192
  """Get configuration for a specific adapter."""