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.
- clink/__init__.py +19 -0
- clink/agents/__init__.py +30 -0
- clink/agents/base.py +70 -0
- clink/agents/claude.py +7 -0
- clink/agents/codex.py +7 -0
- clink/agents/gemini.py +7 -0
- clink/allowed_roots.py +356 -0
- clink/backend.py +765 -0
- clink/cli.py +594 -0
- clink/constants.py +78 -0
- clink/contracts.py +167 -0
- clink/files.py +70 -0
- clink/generation.py +274 -0
- clink/generation_capabilities.py +207 -0
- clink/generation_contracts.py +214 -0
- clink/generation_policy.py +174 -0
- clink/models.py +243 -0
- clink/native.py +409 -0
- clink/native_adapters.py +244 -0
- clink/native_contracts.py +68 -0
- clink/native_generation.py +421 -0
- clink/native_generation_claude_policy.py +59 -0
- clink/native_generation_contracts.py +264 -0
- clink/native_generation_families.py +218 -0
- clink/native_generation_family_policy.py +14 -0
- clink/native_generation_files.py +153 -0
- clink/native_generation_policy.py +82 -0
- clink/native_policy.py +86 -0
- clink/parsers/__init__.py +34 -0
- clink/parsers/agy.py +53 -0
- clink/parsers/agy_native.py +161 -0
- clink/parsers/agy_native_generation.py +189 -0
- clink/parsers/base.py +209 -0
- clink/parsers/claude.py +104 -0
- clink/parsers/claude_native.py +113 -0
- clink/parsers/claude_native_generation.py +346 -0
- clink/parsers/codex.py +172 -0
- clink/parsers/codex_generation.py +212 -0
- clink/parsers/codex_native.py +236 -0
- clink/parsers/codex_native_generation.py +367 -0
- clink/parsers/gemini.py +110 -0
- clink/parsers/grok.py +63 -0
- clink/parsers/grok_native.py +91 -0
- clink/parsers/grok_native_generation.py +157 -0
- clink/policy.py +180 -0
- clink/registry.py +544 -0
- clink/resources/CODEX-LICENSE +201 -0
- clink/resources/CODEX-NOTICE +6 -0
- clink/resources/PROVENANCE.md +16 -0
- clink/resources/codex-0.166.0-models-direct.json +1284 -0
- clink/resources/codex-0.166.0-models-generation.json +1269 -0
- clink/resources/native-agy-1.4.12-admission.json +746 -0
- clink/resources/native-claude-2.1.304-admission.json +99 -0
- clink/resources/native-generation-claude-2.1.304-admission.json +277 -0
- clink/resources/native-generation-codex-0.166.0-admission.json +309 -0
- clink/resources/native-generation-grok-1.0.70-admission.json +329 -0
- clink/resources/native-grok-1.0.70-admission.json +644 -0
- clink/runner.py +303 -0
- clink/setup.py +399 -0
- clink/tasks.py +695 -0
- clink_cli-0.2.1.dist-info/METADATA +225 -0
- clink_cli-0.2.1.dist-info/RECORD +141 -0
- clink_cli-0.2.1.dist-info/WHEEL +5 -0
- clink_cli-0.2.1.dist-info/entry_points.txt +3 -0
- clink_cli-0.2.1.dist-info/licenses/LICENSE +197 -0
- clink_cli-0.2.1.dist-info/licenses/clink/resources/CODEX-LICENSE +201 -0
- clink_cli-0.2.1.dist-info/licenses/clink/resources/CODEX-NOTICE +6 -0
- clink_cli-0.2.1.dist-info/top_level.txt +7 -0
- conf/__init__.py +1 -0
- conf/cli_clients/agy.json +40 -0
- conf/cli_clients/claude.json +39 -0
- conf/cli_clients/codex.json +40 -0
- conf/cli_clients/gemini.json +23 -0
- conf/cli_clients/grok.json +40 -0
- config.py +40 -0
- server.py +896 -0
- systemprompts/__init__.py +35 -0
- systemprompts/analyze_prompt.py +87 -0
- systemprompts/chat_prompt.py +57 -0
- systemprompts/clink/codex_codereviewer.txt +8 -0
- systemprompts/clink/default.txt +8 -0
- systemprompts/clink/default_codereviewer.txt +8 -0
- systemprompts/clink/default_planner.txt +7 -0
- systemprompts/clink/native_codereviewer.txt +1 -0
- systemprompts/clink/native_default.txt +1 -0
- systemprompts/clink/native_planner.txt +1 -0
- systemprompts/codereview_prompt.py +91 -0
- systemprompts/consensus_prompt.py +120 -0
- systemprompts/debug_prompt.py +150 -0
- systemprompts/docgen_prompt.py +252 -0
- systemprompts/generate_code_prompt.py +181 -0
- systemprompts/planner_prompt.py +127 -0
- systemprompts/precommit_prompt.py +179 -0
- systemprompts/refactor_prompt.py +323 -0
- systemprompts/secaudit_prompt.py +420 -0
- systemprompts/testgen_prompt.py +133 -0
- systemprompts/thinkdeep_prompt.py +55 -0
- systemprompts/tracer_prompt.py +145 -0
- tools/__init__.py +43 -0
- tools/analyze.py +583 -0
- tools/apilookup.py +97 -0
- tools/challenge.py +198 -0
- tools/chat.py +187 -0
- tools/clink.py +130 -0
- tools/codereview.py +724 -0
- tools/consensus.py +790 -0
- tools/debug.py +573 -0
- tools/docgen.py +577 -0
- tools/listmodels.py +48 -0
- tools/models.py +373 -0
- tools/planner.py +533 -0
- tools/precommit.py +776 -0
- tools/refactor.py +645 -0
- tools/secaudit.py +685 -0
- tools/shared/__init__.py +19 -0
- tools/shared/base_models.py +167 -0
- tools/shared/base_tool.py +659 -0
- tools/shared/exceptions.py +20 -0
- tools/shared/schema_builders.py +159 -0
- tools/simple/__init__.py +18 -0
- tools/simple/base.py +539 -0
- tools/testgen.py +513 -0
- tools/thinkdeep.py +586 -0
- tools/tracer.py +763 -0
- tools/version.py +53 -0
- tools/workflow/__init__.py +22 -0
- tools/workflow/base.py +448 -0
- tools/workflow/schema_builders.py +166 -0
- tools/workflow/workflow_mixin.py +1195 -0
- utils/__init__.py +21 -0
- utils/call_state.py +349 -0
- utils/client_info.py +293 -0
- utils/consensus_manifest.py +131 -0
- utils/conversation_memory.py +582 -0
- utils/env.py +111 -0
- utils/file_types.py +271 -0
- utils/file_utils.py +803 -0
- utils/image_utils.py +94 -0
- utils/security_config.py +163 -0
- utils/storage_backend.py +177 -0
- utils/token_utils.py +54 -0
utils/file_types.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File type definitions and constants for file processing
|
|
3
|
+
|
|
4
|
+
This module centralizes all file type and extension definitions used
|
|
5
|
+
throughout the MCP server for consistent file handling.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Programming language file extensions - core code files
|
|
9
|
+
PROGRAMMING_LANGUAGES = {
|
|
10
|
+
".py", # Python
|
|
11
|
+
".js", # JavaScript
|
|
12
|
+
".ts", # TypeScript
|
|
13
|
+
".jsx", # React JavaScript
|
|
14
|
+
".tsx", # React TypeScript
|
|
15
|
+
".java", # Java
|
|
16
|
+
".cpp", # C++
|
|
17
|
+
".c", # C
|
|
18
|
+
".h", # C/C++ Header
|
|
19
|
+
".hpp", # C++ Header
|
|
20
|
+
".cs", # C#
|
|
21
|
+
".go", # Go
|
|
22
|
+
".rs", # Rust
|
|
23
|
+
".rb", # Ruby
|
|
24
|
+
".php", # PHP
|
|
25
|
+
".swift", # Swift
|
|
26
|
+
".kt", # Kotlin
|
|
27
|
+
".scala", # Scala
|
|
28
|
+
".r", # R
|
|
29
|
+
".m", # Objective-C
|
|
30
|
+
".mm", # Objective-C++
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Script and shell file extensions
|
|
34
|
+
SCRIPTS = {
|
|
35
|
+
".sql", # SQL
|
|
36
|
+
".sh", # Shell
|
|
37
|
+
".bash", # Bash
|
|
38
|
+
".zsh", # Zsh
|
|
39
|
+
".fish", # Fish shell
|
|
40
|
+
".ps1", # PowerShell
|
|
41
|
+
".bat", # Batch
|
|
42
|
+
".cmd", # Command
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Configuration and data file extensions
|
|
46
|
+
CONFIGS = {
|
|
47
|
+
".yml", # YAML
|
|
48
|
+
".yaml", # YAML
|
|
49
|
+
".json", # JSON
|
|
50
|
+
".xml", # XML
|
|
51
|
+
".toml", # TOML
|
|
52
|
+
".ini", # INI
|
|
53
|
+
".cfg", # Config
|
|
54
|
+
".conf", # Config
|
|
55
|
+
".properties", # Properties
|
|
56
|
+
".env", # Environment
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Documentation and markup file extensions
|
|
60
|
+
DOCS = {
|
|
61
|
+
".txt", # Text
|
|
62
|
+
".md", # Markdown
|
|
63
|
+
".rst", # reStructuredText
|
|
64
|
+
".tex", # LaTeX
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Web development file extensions
|
|
68
|
+
WEB = {
|
|
69
|
+
".html", # HTML
|
|
70
|
+
".css", # CSS
|
|
71
|
+
".scss", # Sass
|
|
72
|
+
".sass", # Sass
|
|
73
|
+
".less", # Less
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# Additional text file extensions for logs and data
|
|
77
|
+
TEXT_DATA = {
|
|
78
|
+
".log", # Log files
|
|
79
|
+
".csv", # CSV
|
|
80
|
+
".tsv", # TSV
|
|
81
|
+
".gitignore", # Git ignore
|
|
82
|
+
".dockerfile", # Dockerfile
|
|
83
|
+
".makefile", # Make
|
|
84
|
+
".cmake", # CMake
|
|
85
|
+
".gradle", # Gradle
|
|
86
|
+
".sbt", # SBT
|
|
87
|
+
".pom", # Maven POM
|
|
88
|
+
".lock", # Lock files
|
|
89
|
+
".changeset", # Precommit changeset
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Image file extensions - limited to what AI models actually support
|
|
93
|
+
# Based on OpenAI and Gemini supported formats: PNG, JPEG, GIF, WebP
|
|
94
|
+
IMAGES = {".jpg", ".jpeg", ".png", ".gif", ".webp"}
|
|
95
|
+
|
|
96
|
+
# Binary executable and library extensions
|
|
97
|
+
BINARIES = {
|
|
98
|
+
".exe", # Windows executable
|
|
99
|
+
".dll", # Windows library
|
|
100
|
+
".so", # Linux shared object
|
|
101
|
+
".dylib", # macOS dynamic library
|
|
102
|
+
".bin", # Binary
|
|
103
|
+
".class", # Java class
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Archive and package file extensions
|
|
107
|
+
ARCHIVES = {
|
|
108
|
+
".jar",
|
|
109
|
+
".war",
|
|
110
|
+
".ear", # Java archives
|
|
111
|
+
".zip",
|
|
112
|
+
".tar",
|
|
113
|
+
".gz", # General archives
|
|
114
|
+
".7z",
|
|
115
|
+
".rar", # Compression
|
|
116
|
+
".deb",
|
|
117
|
+
".rpm", # Linux packages
|
|
118
|
+
".dmg",
|
|
119
|
+
".pkg", # macOS packages
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# Derived sets for different use cases
|
|
123
|
+
CODE_EXTENSIONS = PROGRAMMING_LANGUAGES | SCRIPTS | CONFIGS | DOCS | WEB
|
|
124
|
+
PROGRAMMING_EXTENSIONS = PROGRAMMING_LANGUAGES # For line numbering
|
|
125
|
+
TEXT_EXTENSIONS = CODE_EXTENSIONS | TEXT_DATA
|
|
126
|
+
IMAGE_EXTENSIONS = IMAGES
|
|
127
|
+
BINARY_EXTENSIONS = BINARIES | ARCHIVES
|
|
128
|
+
|
|
129
|
+
# All extensions by category for easy access
|
|
130
|
+
FILE_CATEGORIES = {
|
|
131
|
+
"programming": PROGRAMMING_LANGUAGES,
|
|
132
|
+
"scripts": SCRIPTS,
|
|
133
|
+
"configs": CONFIGS,
|
|
134
|
+
"docs": DOCS,
|
|
135
|
+
"web": WEB,
|
|
136
|
+
"text_data": TEXT_DATA,
|
|
137
|
+
"images": IMAGES,
|
|
138
|
+
"binaries": BINARIES,
|
|
139
|
+
"archives": ARCHIVES,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def get_file_category(file_path: str) -> str:
|
|
144
|
+
"""
|
|
145
|
+
Determine the category of a file based on its extension.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
file_path: Path to the file
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Category name or "unknown" if not recognized
|
|
152
|
+
"""
|
|
153
|
+
from pathlib import Path
|
|
154
|
+
|
|
155
|
+
extension = Path(file_path).suffix.lower()
|
|
156
|
+
|
|
157
|
+
for category, extensions in FILE_CATEGORIES.items():
|
|
158
|
+
if extension in extensions:
|
|
159
|
+
return category
|
|
160
|
+
|
|
161
|
+
return "unknown"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def is_code_file(file_path: str) -> bool:
|
|
165
|
+
"""Check if a file is a code file (programming language)."""
|
|
166
|
+
from pathlib import Path
|
|
167
|
+
|
|
168
|
+
return Path(file_path).suffix.lower() in PROGRAMMING_LANGUAGES
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def is_text_file(file_path: str) -> bool:
|
|
172
|
+
"""Check if a file is a text file."""
|
|
173
|
+
from pathlib import Path
|
|
174
|
+
|
|
175
|
+
return Path(file_path).suffix.lower() in TEXT_EXTENSIONS
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def is_binary_file(file_path: str) -> bool:
|
|
179
|
+
"""Check if a file is a binary file."""
|
|
180
|
+
from pathlib import Path
|
|
181
|
+
|
|
182
|
+
return Path(file_path).suffix.lower() in BINARY_EXTENSIONS
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# File-type specific token-to-byte ratios for accurate token estimation
|
|
186
|
+
# Based on empirical analysis of file compression characteristics and tokenization patterns
|
|
187
|
+
TOKEN_ESTIMATION_RATIOS = {
|
|
188
|
+
# Programming languages
|
|
189
|
+
".py": 3.5, # Python - moderate verbosity
|
|
190
|
+
".js": 3.2, # JavaScript - compact syntax
|
|
191
|
+
".ts": 3.3, # TypeScript - type annotations add tokens
|
|
192
|
+
".jsx": 3.1, # React JSX - JSX tags are tokenized efficiently
|
|
193
|
+
".tsx": 3.0, # React TSX - combination of TypeScript + JSX
|
|
194
|
+
".java": 3.6, # Java - verbose syntax, long identifiers
|
|
195
|
+
".cpp": 3.7, # C++ - preprocessor directives, templates
|
|
196
|
+
".c": 3.8, # C - function definitions, struct declarations
|
|
197
|
+
".go": 3.9, # Go - explicit error handling, package names
|
|
198
|
+
".rs": 3.5, # Rust - similar to Python in verbosity
|
|
199
|
+
".php": 3.3, # PHP - mixed HTML/code, variable prefixes
|
|
200
|
+
".rb": 3.6, # Ruby - descriptive method names
|
|
201
|
+
".swift": 3.4, # Swift - modern syntax, type inference
|
|
202
|
+
".kt": 3.5, # Kotlin - similar to modern languages
|
|
203
|
+
".scala": 3.2, # Scala - functional programming, concise
|
|
204
|
+
# Scripts and configuration
|
|
205
|
+
".sh": 4.1, # Shell scripts - commands and paths
|
|
206
|
+
".bat": 4.0, # Batch files - similar to shell
|
|
207
|
+
".ps1": 3.8, # PowerShell - more structured than bash
|
|
208
|
+
".sql": 3.8, # SQL - keywords and table/column names
|
|
209
|
+
# Data and configuration formats
|
|
210
|
+
".json": 2.5, # JSON - lots of punctuation and quotes
|
|
211
|
+
".yaml": 3.0, # YAML - structured but readable
|
|
212
|
+
".yml": 3.0, # YAML (alternative extension)
|
|
213
|
+
".xml": 2.8, # XML - tags and attributes
|
|
214
|
+
".toml": 3.2, # TOML - similar to config files
|
|
215
|
+
# Documentation and text
|
|
216
|
+
".md": 4.2, # Markdown - natural language with formatting
|
|
217
|
+
".txt": 4.0, # Plain text - mostly natural language
|
|
218
|
+
".rst": 4.1, # reStructuredText - documentation format
|
|
219
|
+
# Web technologies
|
|
220
|
+
".html": 2.9, # HTML - tags and attributes
|
|
221
|
+
".css": 3.4, # CSS - properties and selectors
|
|
222
|
+
# Logs and data
|
|
223
|
+
".log": 4.5, # Log files - timestamps, messages, stack traces
|
|
224
|
+
".csv": 3.1, # CSV - data with delimiters
|
|
225
|
+
# Infrastructure files
|
|
226
|
+
".dockerfile": 3.7, # Dockerfile - commands and paths
|
|
227
|
+
".tf": 3.5, # Terraform - infrastructure as code
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def get_token_estimation_ratio(file_path: str) -> float:
|
|
232
|
+
"""
|
|
233
|
+
Get the token estimation ratio for a file based on its extension.
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
file_path: Path to the file
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
Token-to-byte ratio for the file type (default: 3.5 for unknown types)
|
|
240
|
+
"""
|
|
241
|
+
from pathlib import Path
|
|
242
|
+
|
|
243
|
+
extension = Path(file_path).suffix.lower()
|
|
244
|
+
return TOKEN_ESTIMATION_RATIOS.get(extension, 3.5) # Conservative default
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
# MIME type mappings for image files - limited to what AI models actually support
|
|
248
|
+
# Based on OpenAI and Gemini supported formats: PNG, JPEG, GIF, WebP
|
|
249
|
+
IMAGE_MIME_TYPES = {
|
|
250
|
+
".jpg": "image/jpeg",
|
|
251
|
+
".jpeg": "image/jpeg",
|
|
252
|
+
".png": "image/png",
|
|
253
|
+
".gif": "image/gif",
|
|
254
|
+
".webp": "image/webp",
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def get_image_mime_type(extension: str) -> str:
|
|
259
|
+
"""
|
|
260
|
+
Get the MIME type for an image file extension.
|
|
261
|
+
|
|
262
|
+
Args:
|
|
263
|
+
extension: File extension (with or without leading dot)
|
|
264
|
+
|
|
265
|
+
Returns:
|
|
266
|
+
MIME type string (default: image/jpeg for unknown extensions)
|
|
267
|
+
"""
|
|
268
|
+
if not extension.startswith("."):
|
|
269
|
+
extension = "." + extension
|
|
270
|
+
extension = extension.lower()
|
|
271
|
+
return IMAGE_MIME_TYPES.get(extension, "image/jpeg")
|