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,159 @@
1
+ """
2
+ Core schema building functionality for PAL MCP tools.
3
+
4
+ This module provides base schema generation functionality for simple tools.
5
+ Workflow-specific schema building is located in workflow/schema_builders.py
6
+ to maintain proper separation of concerns.
7
+ """
8
+
9
+ from typing import Any
10
+
11
+ from .base_models import COMMON_FIELD_DESCRIPTIONS
12
+
13
+
14
+ class SchemaBuilder:
15
+ """
16
+ Base schema builder for simple MCP tools.
17
+
18
+ This class provides static methods to build consistent schemas for simple tools.
19
+ Workflow tools use WorkflowSchemaBuilder in workflow/schema_builders.py.
20
+ """
21
+
22
+ # Common field schemas that can be reused across all tool types
23
+ COMMON_FIELD_SCHEMAS = {
24
+ "cli_name": {"type": "string", "description": COMMON_FIELD_DESCRIPTIONS["cli_name"]},
25
+ "role": {"type": "string", "description": COMMON_FIELD_DESCRIPTIONS["role"]},
26
+ "temperature": {
27
+ "type": "number",
28
+ "description": COMMON_FIELD_DESCRIPTIONS["temperature"],
29
+ "minimum": 0.0,
30
+ "maximum": 1.0,
31
+ },
32
+ "thinking_mode": {
33
+ "type": "string",
34
+ "enum": ["minimal", "low", "medium", "high", "max"],
35
+ "description": COMMON_FIELD_DESCRIPTIONS["thinking_mode"],
36
+ },
37
+ "continuation_id": {
38
+ "type": "string",
39
+ "description": COMMON_FIELD_DESCRIPTIONS["continuation_id"],
40
+ },
41
+ "images": {
42
+ "type": "array",
43
+ "items": {"type": "string"},
44
+ "description": COMMON_FIELD_DESCRIPTIONS["images"],
45
+ },
46
+ }
47
+
48
+ # Simple tool-specific field schemas (workflow tools use relevant_files instead)
49
+ SIMPLE_FIELD_SCHEMAS = {
50
+ "absolute_file_paths": {
51
+ "type": "array",
52
+ "items": {"type": "string"},
53
+ "description": COMMON_FIELD_DESCRIPTIONS["absolute_file_paths"],
54
+ },
55
+ }
56
+
57
+ @staticmethod
58
+ def build_schema(
59
+ tool_specific_fields: dict[str, dict[str, Any]] = None,
60
+ required_fields: list[str] = None,
61
+ model_field_schema: dict[str, Any] = None,
62
+ auto_mode: bool = False,
63
+ require_model: bool = False,
64
+ ) -> dict[str, Any]:
65
+ """
66
+ Build complete schema for simple tools.
67
+
68
+ Args:
69
+ tool_specific_fields: Additional fields specific to the tool
70
+ required_fields: List of required field names
71
+ model_field_schema: Schema for the model field
72
+ auto_mode: Whether the tool is in auto mode (affects model requirement)
73
+
74
+ Returns:
75
+ Complete JSON schema for the tool
76
+ """
77
+ properties = {}
78
+
79
+ # Add common fields (temperature, thinking_mode, etc.)
80
+ properties.update(SchemaBuilder.COMMON_FIELD_SCHEMAS)
81
+
82
+ # Add simple tool-specific fields (files field for simple tools)
83
+ properties.update(SchemaBuilder.SIMPLE_FIELD_SCHEMAS)
84
+
85
+ # Add model field if provided
86
+ if model_field_schema:
87
+ properties["model"] = model_field_schema
88
+
89
+ # Add tool-specific fields if provided
90
+ if tool_specific_fields:
91
+ properties.update(tool_specific_fields)
92
+
93
+ # Build required fields list
94
+ required = list(required_fields) if required_fields else []
95
+
96
+ # Build the complete schema
97
+ schema = {
98
+ "$schema": "http://json-schema.org/draft-07/schema#",
99
+ "type": "object",
100
+ "properties": properties,
101
+ "additionalProperties": False,
102
+ }
103
+
104
+ if required:
105
+ schema["required"] = required
106
+
107
+ return schema
108
+
109
+ @staticmethod
110
+ def get_common_fields() -> dict[str, dict[str, Any]]:
111
+ """Get the standard field schemas for simple tools."""
112
+ return SchemaBuilder.COMMON_FIELD_SCHEMAS.copy()
113
+
114
+ @staticmethod
115
+ def create_field_schema(
116
+ field_type: str,
117
+ description: str,
118
+ enum_values: list[str] = None,
119
+ minimum: float = None,
120
+ maximum: float = None,
121
+ items_type: str = None,
122
+ default: Any = None,
123
+ ) -> dict[str, Any]:
124
+ """
125
+ Helper method to create field schemas with common patterns.
126
+
127
+ Args:
128
+ field_type: JSON schema type ("string", "number", "array", etc.)
129
+ description: Human-readable description of the field
130
+ enum_values: For enum fields, list of allowed values
131
+ minimum: For numeric fields, minimum value
132
+ maximum: For numeric fields, maximum value
133
+ items_type: For array fields, type of array items
134
+ default: Default value for the field
135
+
136
+ Returns:
137
+ JSON schema object for the field
138
+ """
139
+ schema = {
140
+ "type": field_type,
141
+ "description": description,
142
+ }
143
+
144
+ if enum_values:
145
+ schema["enum"] = enum_values
146
+
147
+ if minimum is not None:
148
+ schema["minimum"] = minimum
149
+
150
+ if maximum is not None:
151
+ schema["maximum"] = maximum
152
+
153
+ if items_type and field_type == "array":
154
+ schema["items"] = {"type": items_type}
155
+
156
+ if default is not None:
157
+ schema["default"] = default
158
+
159
+ return schema
@@ -0,0 +1,18 @@
1
+ """
2
+ Simple tools for PAL MCP.
3
+
4
+ Simple tools follow a basic request → AI model → response pattern.
5
+ They inherit from SimpleTool which provides streamlined functionality
6
+ for tools that don't need multi-step workflows.
7
+
8
+ Available simple tools:
9
+ - chat: General chat and collaborative thinking
10
+ - consensus: Multi-perspective analysis
11
+ - listmodels: Model listing and information
12
+ - testgen: Test generation
13
+ - tracer: Execution tracing
14
+ """
15
+
16
+ from .base import SimpleTool
17
+
18
+ __all__ = ["SimpleTool"]