mcp-ticketer 0.1.30__py3-none-any.whl → 1.2.11__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.

Files changed (109) hide show
  1. mcp_ticketer/__init__.py +10 -10
  2. mcp_ticketer/__version__.py +3 -3
  3. mcp_ticketer/adapters/__init__.py +2 -0
  4. mcp_ticketer/adapters/aitrackdown.py +796 -46
  5. mcp_ticketer/adapters/asana/__init__.py +15 -0
  6. mcp_ticketer/adapters/asana/adapter.py +1416 -0
  7. mcp_ticketer/adapters/asana/client.py +292 -0
  8. mcp_ticketer/adapters/asana/mappers.py +348 -0
  9. mcp_ticketer/adapters/asana/types.py +146 -0
  10. mcp_ticketer/adapters/github.py +879 -129
  11. mcp_ticketer/adapters/hybrid.py +11 -11
  12. mcp_ticketer/adapters/jira.py +973 -73
  13. mcp_ticketer/adapters/linear/__init__.py +24 -0
  14. mcp_ticketer/adapters/linear/adapter.py +2732 -0
  15. mcp_ticketer/adapters/linear/client.py +344 -0
  16. mcp_ticketer/adapters/linear/mappers.py +420 -0
  17. mcp_ticketer/adapters/linear/queries.py +479 -0
  18. mcp_ticketer/adapters/linear/types.py +360 -0
  19. mcp_ticketer/adapters/linear.py +10 -2315
  20. mcp_ticketer/analysis/__init__.py +23 -0
  21. mcp_ticketer/analysis/orphaned.py +218 -0
  22. mcp_ticketer/analysis/similarity.py +224 -0
  23. mcp_ticketer/analysis/staleness.py +266 -0
  24. mcp_ticketer/cache/memory.py +9 -8
  25. mcp_ticketer/cli/adapter_diagnostics.py +421 -0
  26. mcp_ticketer/cli/auggie_configure.py +116 -15
  27. mcp_ticketer/cli/codex_configure.py +274 -82
  28. mcp_ticketer/cli/configure.py +888 -151
  29. mcp_ticketer/cli/diagnostics.py +400 -157
  30. mcp_ticketer/cli/discover.py +297 -26
  31. mcp_ticketer/cli/gemini_configure.py +119 -26
  32. mcp_ticketer/cli/init_command.py +880 -0
  33. mcp_ticketer/cli/instruction_commands.py +435 -0
  34. mcp_ticketer/cli/linear_commands.py +616 -0
  35. mcp_ticketer/cli/main.py +203 -1165
  36. mcp_ticketer/cli/mcp_configure.py +474 -90
  37. mcp_ticketer/cli/mcp_server_commands.py +415 -0
  38. mcp_ticketer/cli/migrate_config.py +12 -8
  39. mcp_ticketer/cli/platform_commands.py +123 -0
  40. mcp_ticketer/cli/platform_detection.py +418 -0
  41. mcp_ticketer/cli/platform_installer.py +513 -0
  42. mcp_ticketer/cli/python_detection.py +126 -0
  43. mcp_ticketer/cli/queue_commands.py +15 -15
  44. mcp_ticketer/cli/setup_command.py +639 -0
  45. mcp_ticketer/cli/simple_health.py +90 -65
  46. mcp_ticketer/cli/ticket_commands.py +1013 -0
  47. mcp_ticketer/cli/update_checker.py +313 -0
  48. mcp_ticketer/cli/utils.py +114 -66
  49. mcp_ticketer/core/__init__.py +24 -1
  50. mcp_ticketer/core/adapter.py +250 -16
  51. mcp_ticketer/core/config.py +145 -37
  52. mcp_ticketer/core/env_discovery.py +101 -22
  53. mcp_ticketer/core/env_loader.py +349 -0
  54. mcp_ticketer/core/exceptions.py +160 -0
  55. mcp_ticketer/core/http_client.py +26 -26
  56. mcp_ticketer/core/instructions.py +405 -0
  57. mcp_ticketer/core/label_manager.py +732 -0
  58. mcp_ticketer/core/mappers.py +42 -30
  59. mcp_ticketer/core/models.py +280 -28
  60. mcp_ticketer/core/onepassword_secrets.py +379 -0
  61. mcp_ticketer/core/project_config.py +183 -49
  62. mcp_ticketer/core/registry.py +3 -3
  63. mcp_ticketer/core/session_state.py +171 -0
  64. mcp_ticketer/core/state_matcher.py +592 -0
  65. mcp_ticketer/core/url_parser.py +425 -0
  66. mcp_ticketer/core/validators.py +69 -0
  67. mcp_ticketer/defaults/ticket_instructions.md +644 -0
  68. mcp_ticketer/mcp/__init__.py +29 -1
  69. mcp_ticketer/mcp/__main__.py +60 -0
  70. mcp_ticketer/mcp/server/__init__.py +25 -0
  71. mcp_ticketer/mcp/server/__main__.py +60 -0
  72. mcp_ticketer/mcp/server/constants.py +58 -0
  73. mcp_ticketer/mcp/server/diagnostic_helper.py +175 -0
  74. mcp_ticketer/mcp/server/dto.py +195 -0
  75. mcp_ticketer/mcp/server/main.py +1343 -0
  76. mcp_ticketer/mcp/server/response_builder.py +206 -0
  77. mcp_ticketer/mcp/server/routing.py +655 -0
  78. mcp_ticketer/mcp/server/server_sdk.py +151 -0
  79. mcp_ticketer/mcp/server/tools/__init__.py +56 -0
  80. mcp_ticketer/mcp/server/tools/analysis_tools.py +495 -0
  81. mcp_ticketer/mcp/server/tools/attachment_tools.py +226 -0
  82. mcp_ticketer/mcp/server/tools/bulk_tools.py +273 -0
  83. mcp_ticketer/mcp/server/tools/comment_tools.py +152 -0
  84. mcp_ticketer/mcp/server/tools/config_tools.py +1439 -0
  85. mcp_ticketer/mcp/server/tools/diagnostic_tools.py +211 -0
  86. mcp_ticketer/mcp/server/tools/hierarchy_tools.py +921 -0
  87. mcp_ticketer/mcp/server/tools/instruction_tools.py +300 -0
  88. mcp_ticketer/mcp/server/tools/label_tools.py +948 -0
  89. mcp_ticketer/mcp/server/tools/pr_tools.py +152 -0
  90. mcp_ticketer/mcp/server/tools/search_tools.py +215 -0
  91. mcp_ticketer/mcp/server/tools/session_tools.py +170 -0
  92. mcp_ticketer/mcp/server/tools/ticket_tools.py +1268 -0
  93. mcp_ticketer/mcp/server/tools/user_ticket_tools.py +547 -0
  94. mcp_ticketer/queue/__init__.py +1 -0
  95. mcp_ticketer/queue/health_monitor.py +168 -136
  96. mcp_ticketer/queue/manager.py +95 -25
  97. mcp_ticketer/queue/queue.py +40 -21
  98. mcp_ticketer/queue/run_worker.py +6 -1
  99. mcp_ticketer/queue/ticket_registry.py +213 -155
  100. mcp_ticketer/queue/worker.py +109 -49
  101. mcp_ticketer-1.2.11.dist-info/METADATA +792 -0
  102. mcp_ticketer-1.2.11.dist-info/RECORD +110 -0
  103. mcp_ticketer/mcp/server.py +0 -1895
  104. mcp_ticketer-0.1.30.dist-info/METADATA +0 -413
  105. mcp_ticketer-0.1.30.dist-info/RECORD +0 -49
  106. {mcp_ticketer-0.1.30.dist-info → mcp_ticketer-1.2.11.dist-info}/WHEEL +0 -0
  107. {mcp_ticketer-0.1.30.dist-info → mcp_ticketer-1.2.11.dist-info}/entry_points.txt +0 -0
  108. {mcp_ticketer-0.1.30.dist-info → mcp_ticketer-1.2.11.dist-info}/licenses/LICENSE +0 -0
  109. {mcp_ticketer-0.1.30.dist-info → mcp_ticketer-1.2.11.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,405 @@
1
+ """Ticket writing instructions management.
2
+
3
+ This module provides a unified interface for managing ticket writing instructions
4
+ that guide AI agents and users in creating well-structured, consistent tickets.
5
+
6
+ The instructions can be:
7
+ - Default (embedded in the package)
8
+ - Custom (project-specific, stored in .mcp-ticketer/instructions.md)
9
+
10
+ Example:
11
+ >>> from mcp_ticketer.core.instructions import get_instructions
12
+ >>> instructions = get_instructions()
13
+ >>> print(instructions)
14
+
15
+ >>> # For project-specific management
16
+ >>> from mcp_ticketer.core.instructions import TicketInstructionsManager
17
+ >>> manager = TicketInstructionsManager(project_dir="/path/to/project")
18
+ >>> manager.set_instructions("Custom instructions here...")
19
+ >>> if manager.has_custom_instructions():
20
+ ... print("Using custom instructions")
21
+
22
+ """
23
+
24
+ from __future__ import annotations
25
+
26
+ import logging
27
+ from pathlib import Path
28
+
29
+ from .exceptions import MCPTicketerError
30
+
31
+ logger = logging.getLogger(__name__)
32
+
33
+
34
+ class InstructionsError(MCPTicketerError):
35
+ """Base exception for instructions-related errors.
36
+
37
+ Raised when there are issues loading, saving, or validating ticket
38
+ writing instructions.
39
+ """
40
+
41
+ pass
42
+
43
+
44
+ class InstructionsNotFoundError(InstructionsError):
45
+ """Exception raised when instructions file cannot be found.
46
+
47
+ This typically occurs when trying to load custom instructions from a
48
+ file path that doesn't exist, or when the default instructions file
49
+ is missing from the package.
50
+ """
51
+
52
+ pass
53
+
54
+
55
+ class InstructionsValidationError(InstructionsError):
56
+ """Exception raised when instructions content is invalid.
57
+
58
+ Raised when instructions content fails validation rules such as:
59
+ - Empty content
60
+ - Content too short (< 100 characters)
61
+ - Invalid encoding
62
+ """
63
+
64
+ pass
65
+
66
+
67
+ class TicketInstructionsManager:
68
+ """Manages ticket writing instructions for a project.
69
+
70
+ This class handles loading, saving, and validating ticket writing instructions.
71
+ It supports both default (embedded) instructions and custom project-specific
72
+ instructions.
73
+
74
+ The default instructions are embedded in the package at:
75
+ src/mcp_ticketer/defaults/ticket_instructions.md
76
+
77
+ Custom instructions are stored in the project directory at:
78
+ {project_dir}/.mcp-ticketer/instructions.md
79
+
80
+ Attributes:
81
+ project_dir: Path to the project root directory
82
+
83
+ Example:
84
+ >>> manager = TicketInstructionsManager("/path/to/project")
85
+ >>> instructions = manager.get_instructions()
86
+ >>> print(f"Using {'custom' if manager.has_custom_instructions() else 'default'}")
87
+
88
+ >>> # Set custom instructions
89
+ >>> manager.set_instructions("My custom guidelines...")
90
+ >>> assert manager.has_custom_instructions()
91
+
92
+ >>> # Revert to defaults
93
+ >>> manager.delete_instructions()
94
+ >>> assert not manager.has_custom_instructions()
95
+
96
+ """
97
+
98
+ # Class-level constant for custom instructions filename
99
+ INSTRUCTIONS_FILENAME = "instructions.md"
100
+ DEFAULT_INSTRUCTIONS_FILENAME = "ticket_instructions.md"
101
+ CONFIG_DIR = ".mcp-ticketer"
102
+
103
+ def __init__(self, project_dir: str | Path | None = None):
104
+ """Initialize the instructions manager.
105
+
106
+ Args:
107
+ project_dir: Path to the project root directory. If None, uses current
108
+ working directory. The project directory is where the .mcp-ticketer
109
+ folder will be created for custom instructions.
110
+
111
+ Raises:
112
+ InstructionsError: If project_dir is invalid or inaccessible
113
+
114
+ """
115
+ if project_dir is None:
116
+ project_dir = Path.cwd()
117
+ else:
118
+ project_dir = Path(project_dir)
119
+
120
+ if not project_dir.exists():
121
+ raise InstructionsError(f"Project directory does not exist: {project_dir}")
122
+
123
+ if not project_dir.is_dir():
124
+ raise InstructionsError(f"Project path is not a directory: {project_dir}")
125
+
126
+ self.project_dir = project_dir.resolve()
127
+ logger.debug(f"Initialized TicketInstructionsManager for: {self.project_dir}")
128
+
129
+ def get_instructions(self) -> str:
130
+ """Get the current ticket writing instructions.
131
+
132
+ Returns custom instructions if they exist, otherwise returns the default
133
+ embedded instructions.
134
+
135
+ Returns:
136
+ The ticket writing instructions as a string
137
+
138
+ Raises:
139
+ InstructionsError: If instructions cannot be loaded
140
+ InstructionsNotFoundError: If default instructions are missing (package error)
141
+
142
+ Example:
143
+ >>> manager = TicketInstructionsManager()
144
+ >>> instructions = manager.get_instructions()
145
+ >>> # Use instructions to guide ticket creation
146
+ >>> print(instructions[:100])
147
+
148
+ """
149
+ if self.has_custom_instructions():
150
+ logger.debug("Loading custom instructions")
151
+ custom_path = self.get_instructions_path()
152
+ try:
153
+ return custom_path.read_text(encoding="utf-8")
154
+ except Exception as e:
155
+ raise InstructionsError(
156
+ f"Failed to read custom instructions from {custom_path}: {e}"
157
+ ) from e
158
+ else:
159
+ logger.debug("Loading default instructions")
160
+ return self.get_default_instructions()
161
+
162
+ def get_default_instructions(self) -> str:
163
+ """Get the default embedded ticket writing instructions.
164
+
165
+ The default instructions are shipped with the package and provide
166
+ comprehensive guidelines for ticket creation.
167
+
168
+ Returns:
169
+ The default ticket writing instructions as a string
170
+
171
+ Raises:
172
+ InstructionsNotFoundError: If the default instructions file is missing
173
+ from the package (indicates package corruption or installation issue)
174
+
175
+ Example:
176
+ >>> manager = TicketInstructionsManager()
177
+ >>> defaults = manager.get_default_instructions()
178
+ >>> # Always returns the same content regardless of project
179
+
180
+ """
181
+ # Get the path to the defaults directory (sibling to core)
182
+ package_root = Path(__file__).parent.parent
183
+ default_path = package_root / "defaults" / self.DEFAULT_INSTRUCTIONS_FILENAME
184
+
185
+ if not default_path.exists():
186
+ raise InstructionsNotFoundError(
187
+ f"Default instructions file not found at: {default_path}. "
188
+ "This indicates a package installation issue."
189
+ )
190
+
191
+ try:
192
+ content = default_path.read_text(encoding="utf-8")
193
+ logger.debug(f"Loaded default instructions from {default_path}")
194
+ return content
195
+ except Exception as e:
196
+ raise InstructionsError(
197
+ f"Failed to read default instructions from {default_path}: {e}"
198
+ ) from e
199
+
200
+ def set_instructions(self, content: str) -> None:
201
+ r"""Set custom ticket writing instructions for the project.
202
+
203
+ Creates or overwrites the custom instructions file in the project's
204
+ .mcp-ticketer directory. The content is validated before saving.
205
+
206
+ Args:
207
+ content: The custom instructions content to save
208
+
209
+ Raises:
210
+ InstructionsValidationError: If content fails validation
211
+ InstructionsError: If instructions cannot be written to disk
212
+
213
+ Example:
214
+ >>> manager = TicketInstructionsManager()
215
+ >>> custom = "# My Team's Ticket Guidelines\n\n..."
216
+ >>> manager.set_instructions(custom)
217
+ >>> assert manager.has_custom_instructions()
218
+
219
+ """
220
+ # Validate content
221
+ self._validate_instructions(content)
222
+
223
+ # Ensure config directory exists
224
+ config_dir = self.project_dir / self.CONFIG_DIR
225
+ config_dir.mkdir(exist_ok=True, parents=True)
226
+
227
+ # Write instructions file
228
+ instructions_path = self.get_instructions_path()
229
+ try:
230
+ instructions_path.write_text(content, encoding="utf-8")
231
+ logger.info(f"Saved custom instructions to {instructions_path}")
232
+ except Exception as e:
233
+ raise InstructionsError(
234
+ f"Failed to write instructions to {instructions_path}: {e}"
235
+ ) from e
236
+
237
+ def set_instructions_from_file(self, file_path: str | Path) -> None:
238
+ """Load and set custom instructions from a file.
239
+
240
+ Reads instructions from the specified file and sets them as custom
241
+ instructions for the project. The file content is validated before saving.
242
+
243
+ Args:
244
+ file_path: Path to the file containing instructions
245
+
246
+ Raises:
247
+ InstructionsNotFoundError: If the source file doesn't exist
248
+ InstructionsValidationError: If file content fails validation
249
+ InstructionsError: If instructions cannot be loaded or saved
250
+
251
+ Example:
252
+ >>> manager = TicketInstructionsManager()
253
+ >>> manager.set_instructions_from_file("team_guidelines.md")
254
+ >>> assert manager.has_custom_instructions()
255
+
256
+ """
257
+ source_path = Path(file_path)
258
+
259
+ if not source_path.exists():
260
+ raise InstructionsNotFoundError(
261
+ f"Instructions file not found: {source_path}"
262
+ )
263
+
264
+ if not source_path.is_file():
265
+ raise InstructionsError(f"Path is not a file: {source_path}")
266
+
267
+ try:
268
+ content = source_path.read_text(encoding="utf-8")
269
+ logger.debug(f"Read instructions from {source_path}")
270
+ except Exception as e:
271
+ raise InstructionsError(
272
+ f"Failed to read instructions from {source_path}: {e}"
273
+ ) from e
274
+
275
+ # Use set_instructions to validate and save
276
+ self.set_instructions(content)
277
+
278
+ def delete_instructions(self) -> bool:
279
+ """Delete custom instructions and revert to defaults.
280
+
281
+ Removes the custom instructions file if it exists. After deletion,
282
+ get_instructions() will return the default instructions.
283
+
284
+ Returns:
285
+ True if custom instructions were deleted, False if they didn't exist
286
+
287
+ Raises:
288
+ InstructionsError: If instructions file cannot be deleted
289
+
290
+ Example:
291
+ >>> manager = TicketInstructionsManager()
292
+ >>> manager.set_instructions("Custom instructions")
293
+ >>> assert manager.delete_instructions() # Returns True
294
+ >>> assert not manager.has_custom_instructions()
295
+ >>> assert not manager.delete_instructions() # Returns False
296
+
297
+ """
298
+ instructions_path = self.get_instructions_path()
299
+
300
+ if not instructions_path.exists():
301
+ logger.debug("No custom instructions to delete")
302
+ return False
303
+
304
+ try:
305
+ instructions_path.unlink()
306
+ logger.info(f"Deleted custom instructions at {instructions_path}")
307
+ return True
308
+ except Exception as e:
309
+ raise InstructionsError(
310
+ f"Failed to delete instructions at {instructions_path}: {e}"
311
+ ) from e
312
+
313
+ def has_custom_instructions(self) -> bool:
314
+ """Check if custom instructions exist for this project.
315
+
316
+ Returns:
317
+ True if custom instructions file exists, False otherwise
318
+
319
+ Example:
320
+ >>> manager = TicketInstructionsManager()
321
+ >>> if manager.has_custom_instructions():
322
+ ... print("Using project-specific guidelines")
323
+ ... else:
324
+ ... print("Using default guidelines")
325
+
326
+ """
327
+ return self.get_instructions_path().exists()
328
+
329
+ def get_instructions_path(self) -> Path:
330
+ """Get the path to the custom instructions file.
331
+
332
+ Returns:
333
+ Path object pointing to where custom instructions are (or would be) stored
334
+
335
+ Note:
336
+ This returns the path even if the file doesn't exist yet. Use
337
+ has_custom_instructions() to check if the file exists.
338
+
339
+ Example:
340
+ >>> manager = TicketInstructionsManager("/path/to/project")
341
+ >>> path = manager.get_instructions_path()
342
+ >>> print(path) # /path/to/project/.mcp-ticketer/instructions.md
343
+
344
+ """
345
+ return self.project_dir / self.CONFIG_DIR / self.INSTRUCTIONS_FILENAME
346
+
347
+ def _validate_instructions(self, content: str) -> None:
348
+ """Validate instructions content.
349
+
350
+ Performs validation checks on instructions content:
351
+ - Not empty
352
+ - Minimum length (100 characters)
353
+ - Contains markdown headers (warning only)
354
+
355
+ Args:
356
+ content: The instructions content to validate
357
+
358
+ Raises:
359
+ InstructionsValidationError: If content fails validation
360
+
361
+ """
362
+ if not content or not content.strip():
363
+ raise InstructionsValidationError("Instructions content cannot be empty")
364
+
365
+ if len(content.strip()) < 100:
366
+ raise InstructionsValidationError(
367
+ f"Instructions content too short ({len(content)} characters). "
368
+ "Minimum 100 characters required for meaningful guidelines."
369
+ )
370
+
371
+ # Warn if no markdown headers (not an error, just a quality check)
372
+ if not any(line.strip().startswith("#") for line in content.split("\n")):
373
+ logger.warning(
374
+ "Instructions don't contain markdown headers. "
375
+ "Consider using headers for better structure."
376
+ )
377
+
378
+
379
+ def get_instructions(project_dir: str | Path | None = None) -> str:
380
+ """Get ticket writing instructions for a project.
381
+
382
+ This is a shorthand for creating a TicketInstructionsManager and calling
383
+ get_instructions(). Useful for simple cases where you just need the content.
384
+
385
+ Args:
386
+ project_dir: Path to the project root directory. If None, uses current
387
+ working directory.
388
+
389
+ Returns:
390
+ The ticket writing instructions (custom if available, otherwise default)
391
+
392
+ Raises:
393
+ InstructionsError: If instructions cannot be loaded
394
+
395
+ Example:
396
+ >>> from mcp_ticketer.core.instructions import get_instructions
397
+ >>> instructions = get_instructions()
398
+ >>> # Use instructions to guide ticket creation
399
+
400
+ >>> # For specific project
401
+ >>> instructions = get_instructions("/path/to/project")
402
+
403
+ """
404
+ manager = TicketInstructionsManager(project_dir)
405
+ return manager.get_instructions()