mcp-ticketer 0.1.26__py3-none-any.whl → 0.1.27__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.27"
4
4
  __version_info__ = tuple(int(part) for part in __version__.split("."))
5
5
 
6
6
  # Package metadata
@@ -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:
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(