clink-cli 0.2.1__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.
Files changed (141) hide show
  1. clink/__init__.py +19 -0
  2. clink/agents/__init__.py +30 -0
  3. clink/agents/base.py +70 -0
  4. clink/agents/claude.py +7 -0
  5. clink/agents/codex.py +7 -0
  6. clink/agents/gemini.py +7 -0
  7. clink/allowed_roots.py +356 -0
  8. clink/backend.py +765 -0
  9. clink/cli.py +594 -0
  10. clink/constants.py +78 -0
  11. clink/contracts.py +167 -0
  12. clink/files.py +70 -0
  13. clink/generation.py +274 -0
  14. clink/generation_capabilities.py +207 -0
  15. clink/generation_contracts.py +214 -0
  16. clink/generation_policy.py +174 -0
  17. clink/models.py +243 -0
  18. clink/native.py +409 -0
  19. clink/native_adapters.py +244 -0
  20. clink/native_contracts.py +68 -0
  21. clink/native_generation.py +421 -0
  22. clink/native_generation_claude_policy.py +59 -0
  23. clink/native_generation_contracts.py +264 -0
  24. clink/native_generation_families.py +218 -0
  25. clink/native_generation_family_policy.py +14 -0
  26. clink/native_generation_files.py +153 -0
  27. clink/native_generation_policy.py +82 -0
  28. clink/native_policy.py +86 -0
  29. clink/parsers/__init__.py +34 -0
  30. clink/parsers/agy.py +53 -0
  31. clink/parsers/agy_native.py +161 -0
  32. clink/parsers/agy_native_generation.py +189 -0
  33. clink/parsers/base.py +209 -0
  34. clink/parsers/claude.py +104 -0
  35. clink/parsers/claude_native.py +113 -0
  36. clink/parsers/claude_native_generation.py +346 -0
  37. clink/parsers/codex.py +172 -0
  38. clink/parsers/codex_generation.py +212 -0
  39. clink/parsers/codex_native.py +236 -0
  40. clink/parsers/codex_native_generation.py +367 -0
  41. clink/parsers/gemini.py +110 -0
  42. clink/parsers/grok.py +63 -0
  43. clink/parsers/grok_native.py +91 -0
  44. clink/parsers/grok_native_generation.py +157 -0
  45. clink/policy.py +180 -0
  46. clink/registry.py +544 -0
  47. clink/resources/CODEX-LICENSE +201 -0
  48. clink/resources/CODEX-NOTICE +6 -0
  49. clink/resources/PROVENANCE.md +16 -0
  50. clink/resources/codex-0.166.0-models-direct.json +1284 -0
  51. clink/resources/codex-0.166.0-models-generation.json +1269 -0
  52. clink/resources/native-agy-1.4.12-admission.json +746 -0
  53. clink/resources/native-claude-2.1.304-admission.json +99 -0
  54. clink/resources/native-generation-claude-2.1.304-admission.json +277 -0
  55. clink/resources/native-generation-codex-0.166.0-admission.json +309 -0
  56. clink/resources/native-generation-grok-1.0.70-admission.json +329 -0
  57. clink/resources/native-grok-1.0.70-admission.json +644 -0
  58. clink/runner.py +303 -0
  59. clink/setup.py +399 -0
  60. clink/tasks.py +695 -0
  61. clink_cli-0.2.1.dist-info/METADATA +225 -0
  62. clink_cli-0.2.1.dist-info/RECORD +141 -0
  63. clink_cli-0.2.1.dist-info/WHEEL +5 -0
  64. clink_cli-0.2.1.dist-info/entry_points.txt +3 -0
  65. clink_cli-0.2.1.dist-info/licenses/LICENSE +197 -0
  66. clink_cli-0.2.1.dist-info/licenses/clink/resources/CODEX-LICENSE +201 -0
  67. clink_cli-0.2.1.dist-info/licenses/clink/resources/CODEX-NOTICE +6 -0
  68. clink_cli-0.2.1.dist-info/top_level.txt +7 -0
  69. conf/__init__.py +1 -0
  70. conf/cli_clients/agy.json +40 -0
  71. conf/cli_clients/claude.json +39 -0
  72. conf/cli_clients/codex.json +40 -0
  73. conf/cli_clients/gemini.json +23 -0
  74. conf/cli_clients/grok.json +40 -0
  75. config.py +40 -0
  76. server.py +896 -0
  77. systemprompts/__init__.py +35 -0
  78. systemprompts/analyze_prompt.py +87 -0
  79. systemprompts/chat_prompt.py +57 -0
  80. systemprompts/clink/codex_codereviewer.txt +8 -0
  81. systemprompts/clink/default.txt +8 -0
  82. systemprompts/clink/default_codereviewer.txt +8 -0
  83. systemprompts/clink/default_planner.txt +7 -0
  84. systemprompts/clink/native_codereviewer.txt +1 -0
  85. systemprompts/clink/native_default.txt +1 -0
  86. systemprompts/clink/native_planner.txt +1 -0
  87. systemprompts/codereview_prompt.py +91 -0
  88. systemprompts/consensus_prompt.py +120 -0
  89. systemprompts/debug_prompt.py +150 -0
  90. systemprompts/docgen_prompt.py +252 -0
  91. systemprompts/generate_code_prompt.py +181 -0
  92. systemprompts/planner_prompt.py +127 -0
  93. systemprompts/precommit_prompt.py +179 -0
  94. systemprompts/refactor_prompt.py +323 -0
  95. systemprompts/secaudit_prompt.py +420 -0
  96. systemprompts/testgen_prompt.py +133 -0
  97. systemprompts/thinkdeep_prompt.py +55 -0
  98. systemprompts/tracer_prompt.py +145 -0
  99. tools/__init__.py +43 -0
  100. tools/analyze.py +583 -0
  101. tools/apilookup.py +97 -0
  102. tools/challenge.py +198 -0
  103. tools/chat.py +187 -0
  104. tools/clink.py +130 -0
  105. tools/codereview.py +724 -0
  106. tools/consensus.py +790 -0
  107. tools/debug.py +573 -0
  108. tools/docgen.py +577 -0
  109. tools/listmodels.py +48 -0
  110. tools/models.py +373 -0
  111. tools/planner.py +533 -0
  112. tools/precommit.py +776 -0
  113. tools/refactor.py +645 -0
  114. tools/secaudit.py +685 -0
  115. tools/shared/__init__.py +19 -0
  116. tools/shared/base_models.py +167 -0
  117. tools/shared/base_tool.py +659 -0
  118. tools/shared/exceptions.py +20 -0
  119. tools/shared/schema_builders.py +159 -0
  120. tools/simple/__init__.py +18 -0
  121. tools/simple/base.py +539 -0
  122. tools/testgen.py +513 -0
  123. tools/thinkdeep.py +586 -0
  124. tools/tracer.py +763 -0
  125. tools/version.py +53 -0
  126. tools/workflow/__init__.py +22 -0
  127. tools/workflow/base.py +448 -0
  128. tools/workflow/schema_builders.py +166 -0
  129. tools/workflow/workflow_mixin.py +1195 -0
  130. utils/__init__.py +21 -0
  131. utils/call_state.py +349 -0
  132. utils/client_info.py +293 -0
  133. utils/consensus_manifest.py +131 -0
  134. utils/conversation_memory.py +582 -0
  135. utils/env.py +111 -0
  136. utils/file_types.py +271 -0
  137. utils/file_utils.py +803 -0
  138. utils/image_utils.py +94 -0
  139. utils/security_config.py +163 -0
  140. utils/storage_backend.py +177 -0
  141. utils/token_utils.py +54 -0
@@ -0,0 +1,19 @@
1
+ """
2
+ Shared infrastructure for PAL MCP tools.
3
+
4
+ This module contains the core base classes and utilities that are shared
5
+ across all tool types. It provides the foundation for the tool architecture.
6
+ """
7
+
8
+ from .base_models import BaseWorkflowRequest, ConsolidatedFindings, ToolRequest, WorkflowRequest
9
+ from .base_tool import BaseTool
10
+ from .schema_builders import SchemaBuilder
11
+
12
+ __all__ = [
13
+ "BaseTool",
14
+ "ToolRequest",
15
+ "BaseWorkflowRequest",
16
+ "WorkflowRequest",
17
+ "ConsolidatedFindings",
18
+ "SchemaBuilder",
19
+ ]
@@ -0,0 +1,167 @@
1
+ """
2
+ Base models for PAL MCP tools.
3
+
4
+ This module contains the shared Pydantic models used across all tools,
5
+ extracted to avoid circular imports and promote code reuse.
6
+
7
+ Key Models:
8
+ - ToolRequest: Base request model for all tools
9
+ - WorkflowRequest: Extended request model for workflow-based tools
10
+ - ConsolidatedFindings: Model for tracking workflow progress
11
+ """
12
+
13
+ import logging
14
+ from typing import Optional
15
+
16
+ from pydantic import BaseModel, Field, field_validator
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ # Shared field descriptions to avoid duplication
22
+ COMMON_FIELD_DESCRIPTIONS = {
23
+ "model": "Native CLI model identifier. Omitted, null, or auto uses role/client/native defaults. No provider alias translation.",
24
+ "cli_name": "Configured CLI client name. Defaults to codex; unavailable selections fail without fallback.",
25
+ "role": "Configured subordinate expertise/style role. Defaults to default; tool instructions retain authority.",
26
+ "temperature": "Legacy sampling setting; unsupported explicit values are unapplied with a warning.",
27
+ "thinking_mode": "Legacy reasoning setting; unsupported explicit values are unapplied with a warning.",
28
+ "continuation_id": (
29
+ "Unique thread continuation ID for multi-turn conversations. Works across different tools. "
30
+ "ALWAYS reuse the last continuation_id you were given—this preserves full conversation context, "
31
+ "files, and findings so the agent can resume seamlessly."
32
+ ),
33
+ "images": "Optional absolute image paths or base64 blobs for visual context.",
34
+ "absolute_file_paths": "Full paths to relevant code",
35
+ }
36
+
37
+ # Workflow-specific field descriptions
38
+ WORKFLOW_FIELD_DESCRIPTIONS = {
39
+ "step": "Current work step content and findings from your overall work",
40
+ "step_number": "Current step number in work sequence (starts at 1)",
41
+ "total_steps": "Estimated total steps needed to complete work",
42
+ "next_step_required": "Whether another work step is needed. When false, aim to reduce total_steps to match step_number to avoid mismatch.",
43
+ "findings": "Important findings, evidence and insights discovered in this step",
44
+ "files_checked": "List of files examined during this work step",
45
+ "relevant_files": "Files identified as relevant to issue/goal (FULL absolute paths to real files/folders - DO NOT SHORTEN)",
46
+ "relevant_context": "Methods/functions identified as involved in the issue",
47
+ "issues_found": "Issues identified with severity levels during work",
48
+ "confidence": (
49
+ "Confidence level: exploring (just starting), low (early investigation), "
50
+ "medium (some evidence), high (strong evidence), very_high (comprehensive understanding), "
51
+ "almost_certain (near complete confidence), certain (100% confidence locally - no external validation needed)"
52
+ ),
53
+ "hypothesis": "Current theory about issue/goal based on work",
54
+ "use_assistant_model": (
55
+ "Use assistant model for expert analysis after workflow steps. "
56
+ "False skips expert analysis, relies solely on your personal investigation. "
57
+ "Defaults to True for comprehensive validation."
58
+ ),
59
+ }
60
+
61
+
62
+ class ToolRequest(BaseModel):
63
+ """
64
+ Base request model for all PAL MCP tools.
65
+
66
+ This model defines common fields that all tools accept, including
67
+ model selection, temperature control, and conversation threading.
68
+ Tool-specific request models should inherit from this class.
69
+ """
70
+
71
+ # Native CLI selection (resolved only when a tool actually delegates).
72
+ cli_name: Optional[str] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["cli_name"])
73
+ role: Optional[str] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["role"])
74
+
75
+ # Model configuration
76
+ model: Optional[str] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["model"])
77
+ temperature: Optional[float] = Field(None, ge=0.0, le=1.0, description=COMMON_FIELD_DESCRIPTIONS["temperature"])
78
+ thinking_mode: Optional[str] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["thinking_mode"])
79
+
80
+ # Conversation support
81
+ continuation_id: Optional[str] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["continuation_id"])
82
+
83
+ # Visual context
84
+ images: Optional[list[str]] = Field(None, description=COMMON_FIELD_DESCRIPTIONS["images"])
85
+
86
+
87
+ class BaseWorkflowRequest(ToolRequest):
88
+ """
89
+ Minimal base request model for workflow tools.
90
+
91
+ This provides only the essential fields that ALL workflow tools need,
92
+ allowing for maximum flexibility in tool-specific implementations.
93
+ """
94
+
95
+ # Core workflow fields that ALL workflow tools need
96
+ step: str = Field(..., description=WORKFLOW_FIELD_DESCRIPTIONS["step"])
97
+ step_number: int = Field(..., ge=1, description=WORKFLOW_FIELD_DESCRIPTIONS["step_number"])
98
+ total_steps: int = Field(..., ge=1, description=WORKFLOW_FIELD_DESCRIPTIONS["total_steps"])
99
+ next_step_required: bool = Field(..., description=WORKFLOW_FIELD_DESCRIPTIONS["next_step_required"])
100
+
101
+
102
+ class WorkflowRequest(BaseWorkflowRequest):
103
+ """
104
+ Extended request model for workflow-based tools.
105
+
106
+ This model extends ToolRequest with fields specific to the workflow
107
+ pattern, where tools perform multi-step work with forced pauses between steps.
108
+
109
+ Used by: debug, precommit, codereview, refactor, thinkdeep, analyze
110
+ """
111
+
112
+ # Required workflow fields
113
+ step: str = Field(..., description=WORKFLOW_FIELD_DESCRIPTIONS["step"])
114
+ step_number: int = Field(..., ge=1, description=WORKFLOW_FIELD_DESCRIPTIONS["step_number"])
115
+ total_steps: int = Field(..., ge=1, description=WORKFLOW_FIELD_DESCRIPTIONS["total_steps"])
116
+ next_step_required: bool = Field(..., description=WORKFLOW_FIELD_DESCRIPTIONS["next_step_required"])
117
+
118
+ # Work tracking fields
119
+ findings: str = Field(..., description=WORKFLOW_FIELD_DESCRIPTIONS["findings"])
120
+ files_checked: list[str] = Field(default_factory=list, description=WORKFLOW_FIELD_DESCRIPTIONS["files_checked"])
121
+ relevant_files: list[str] = Field(default_factory=list, description=WORKFLOW_FIELD_DESCRIPTIONS["relevant_files"])
122
+ relevant_context: list[str] = Field(
123
+ default_factory=list, description=WORKFLOW_FIELD_DESCRIPTIONS["relevant_context"]
124
+ )
125
+ issues_found: list[dict] = Field(default_factory=list, description=WORKFLOW_FIELD_DESCRIPTIONS["issues_found"])
126
+ confidence: str = Field("low", description=WORKFLOW_FIELD_DESCRIPTIONS["confidence"])
127
+
128
+ # Optional workflow fields
129
+ hypothesis: Optional[str] = Field(None, description=WORKFLOW_FIELD_DESCRIPTIONS["hypothesis"])
130
+ use_assistant_model: Optional[bool] = Field(True, description=WORKFLOW_FIELD_DESCRIPTIONS["use_assistant_model"])
131
+
132
+ @field_validator("files_checked", "relevant_files", "relevant_context", mode="before")
133
+ @classmethod
134
+ def convert_string_to_list(cls, v):
135
+ """Convert string inputs to empty lists to handle malformed inputs gracefully."""
136
+ if isinstance(v, str):
137
+ logger.warning("workflow_list_field_invalid type=string action=empty_list")
138
+ return []
139
+ return v
140
+
141
+
142
+ class ConsolidatedFindings(BaseModel):
143
+ """
144
+ Model for tracking consolidated findings across workflow steps.
145
+
146
+ This model accumulates findings, files, methods, and issues
147
+ discovered during multi-step work. It's used by
148
+ BaseWorkflowMixin to track progress across workflow steps.
149
+ """
150
+
151
+ files_checked: set[str] = Field(default_factory=set, description="All files examined across all steps")
152
+ relevant_files: set[str] = Field(
153
+ default_factory=set,
154
+ description="Subset of files_checked identified as relevant for work at hand",
155
+ )
156
+ relevant_context: set[str] = Field(
157
+ default_factory=set, description="All methods/functions identified during overall work"
158
+ )
159
+ findings: list[str] = Field(default_factory=list, description="Chronological findings from each work step")
160
+ hypotheses: list[dict] = Field(default_factory=list, description="Evolution of hypotheses across steps")
161
+ issues_found: list[dict] = Field(default_factory=list, description="All issues with severity levels")
162
+ images: list[str] = Field(default_factory=list, description="Images collected during work")
163
+ confidence: str = Field("low", description="Latest confidence level from steps")
164
+
165
+
166
+ # Tool-specific field descriptions are now declared in each tool file
167
+ # This keeps concerns separated and makes each tool self-contained