karrio-cli 2025.5rc3__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.
- karrio_cli/__init__.py +0 -0
- karrio_cli/__main__.py +105 -0
- karrio_cli/ai/README.md +335 -0
- karrio_cli/ai/__init__.py +0 -0
- karrio_cli/ai/commands.py +102 -0
- karrio_cli/ai/karrio_ai/__init__.py +1 -0
- karrio_cli/ai/karrio_ai/agent.py +972 -0
- karrio_cli/ai/karrio_ai/architecture/INTEGRATION_AGENT_PROMPT.md +497 -0
- karrio_cli/ai/karrio_ai/architecture/MAPPING_AGENT_PROMPT.md +355 -0
- karrio_cli/ai/karrio_ai/architecture/REAL_WORLD_TESTING.md +305 -0
- karrio_cli/ai/karrio_ai/architecture/SCHEMA_AGENT_PROMPT.md +183 -0
- karrio_cli/ai/karrio_ai/architecture/TESTING_AGENT_PROMPT.md +448 -0
- karrio_cli/ai/karrio_ai/architecture/TESTING_GUIDE.md +271 -0
- karrio_cli/ai/karrio_ai/enhanced_tools.py +943 -0
- karrio_cli/ai/karrio_ai/rag_system.py +503 -0
- karrio_cli/ai/karrio_ai/tests/test_agent.py +350 -0
- karrio_cli/ai/karrio_ai/tests/test_real_integration.py +360 -0
- karrio_cli/ai/karrio_ai/tests/test_real_world_scenarios.py +513 -0
- karrio_cli/commands/__init__.py +0 -0
- karrio_cli/commands/codegen.py +336 -0
- karrio_cli/commands/login.py +139 -0
- karrio_cli/commands/plugins.py +168 -0
- karrio_cli/commands/sdk.py +870 -0
- karrio_cli/common/queries.py +101 -0
- karrio_cli/common/utils.py +368 -0
- karrio_cli/resources/__init__.py +0 -0
- karrio_cli/resources/carriers.py +91 -0
- karrio_cli/resources/connections.py +207 -0
- karrio_cli/resources/events.py +151 -0
- karrio_cli/resources/logs.py +151 -0
- karrio_cli/resources/orders.py +144 -0
- karrio_cli/resources/shipments.py +210 -0
- karrio_cli/resources/trackers.py +287 -0
- karrio_cli/templates/__init__.py +9 -0
- karrio_cli/templates/__pycache__/__init__.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/__init__.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/address.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/address.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/docs.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/docs.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/documents.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/documents.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/manifest.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/manifest.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/pickup.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/pickup.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/rates.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/rates.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/sdk.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/sdk.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/shipments.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/shipments.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/tracking.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/tracking.cpython-312.pyc +0 -0
- karrio_cli/templates/address.py +308 -0
- karrio_cli/templates/docs.py +150 -0
- karrio_cli/templates/documents.py +428 -0
- karrio_cli/templates/manifest.py +396 -0
- karrio_cli/templates/pickup.py +839 -0
- karrio_cli/templates/rates.py +638 -0
- karrio_cli/templates/sdk.py +947 -0
- karrio_cli/templates/shipments.py +892 -0
- karrio_cli/templates/tracking.py +437 -0
- karrio_cli-2025.5rc3.dist-info/METADATA +165 -0
- karrio_cli-2025.5rc3.dist-info/RECORD +68 -0
- karrio_cli-2025.5rc3.dist-info/WHEEL +5 -0
- karrio_cli-2025.5rc3.dist-info/entry_points.txt +2 -0
- karrio_cli-2025.5rc3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,360 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Real integration test to evaluate how close we are to 95% completion.
|
4
|
+
|
5
|
+
This test simulates building a complete carrier integration and
|
6
|
+
evaluates the quality and completeness of generated components.
|
7
|
+
"""
|
8
|
+
|
9
|
+
import sys
|
10
|
+
import os
|
11
|
+
import json
|
12
|
+
from pathlib import Path
|
13
|
+
|
14
|
+
# Add the ai module to the path
|
15
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
16
|
+
|
17
|
+
from karrio_ai.agent import (
|
18
|
+
root_agent,
|
19
|
+
analyze_existing_connector,
|
20
|
+
extract_carrier_patterns,
|
21
|
+
generate_carrier_schema,
|
22
|
+
generate_carrier_mappings,
|
23
|
+
generate_integration_tests,
|
24
|
+
assemble_complete_integration,
|
25
|
+
RAG_SYSTEM
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
def test_real_world_integration():
|
30
|
+
"""Test building a complete integration for a hypothetical carrier."""
|
31
|
+
print("=== Testing Real-World Integration Generation ===")
|
32
|
+
|
33
|
+
# Simulate a new carrier - "SwiftShip"
|
34
|
+
carrier_config = {
|
35
|
+
"name": "swiftship",
|
36
|
+
"display_name": "SwiftShip Express",
|
37
|
+
"api_type": "REST",
|
38
|
+
"auth_type": "API_KEY",
|
39
|
+
"base_url": "https://api.swiftship.com/v2",
|
40
|
+
"operations": ["rates", "shipments", "tracking"],
|
41
|
+
"countries": ["US", "CA", "MX"],
|
42
|
+
"test_mode_supported": True
|
43
|
+
}
|
44
|
+
|
45
|
+
# Sample API documentation
|
46
|
+
api_docs = {
|
47
|
+
"rate_request": {
|
48
|
+
"endpoint": "/rates/quote",
|
49
|
+
"method": "POST",
|
50
|
+
"schema": {
|
51
|
+
"type": "object",
|
52
|
+
"properties": {
|
53
|
+
"origin": {
|
54
|
+
"type": "object",
|
55
|
+
"properties": {
|
56
|
+
"postal_code": {"type": "string"},
|
57
|
+
"country_code": {"type": "string"}
|
58
|
+
}
|
59
|
+
},
|
60
|
+
"destination": {
|
61
|
+
"type": "object",
|
62
|
+
"properties": {
|
63
|
+
"postal_code": {"type": "string"},
|
64
|
+
"country_code": {"type": "string"}
|
65
|
+
}
|
66
|
+
},
|
67
|
+
"packages": {
|
68
|
+
"type": "array",
|
69
|
+
"items": {
|
70
|
+
"type": "object",
|
71
|
+
"properties": {
|
72
|
+
"weight": {"type": "number"},
|
73
|
+
"length": {"type": "number"},
|
74
|
+
"width": {"type": "number"},
|
75
|
+
"height": {"type": "number"}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"rate_response": {
|
83
|
+
"schema": {
|
84
|
+
"type": "object",
|
85
|
+
"properties": {
|
86
|
+
"rates": {
|
87
|
+
"type": "array",
|
88
|
+
"items": {
|
89
|
+
"type": "object",
|
90
|
+
"properties": {
|
91
|
+
"service_code": {"type": "string"},
|
92
|
+
"service_name": {"type": "string"},
|
93
|
+
"total_cost": {"type": "number"},
|
94
|
+
"currency": {"type": "string"},
|
95
|
+
"delivery_days": {"type": "integer"},
|
96
|
+
"surcharges": {
|
97
|
+
"type": "array",
|
98
|
+
"items": {
|
99
|
+
"type": "object",
|
100
|
+
"properties": {
|
101
|
+
"name": {"type": "string"},
|
102
|
+
"amount": {"type": "number"}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
results = {}
|
115
|
+
|
116
|
+
try:
|
117
|
+
# Step 1: Analyze similar carriers
|
118
|
+
print("\n1. Analyzing similar carriers...")
|
119
|
+
similar_analysis = analyze_existing_connector("fedex", "all")
|
120
|
+
results["similar_analysis"] = {
|
121
|
+
"success": "error" not in similar_analysis,
|
122
|
+
"files_found": len(similar_analysis.get("files", [])),
|
123
|
+
"patterns_found": len(similar_analysis.get("patterns", []))
|
124
|
+
}
|
125
|
+
print(f"โ Found {results['similar_analysis']['files_found']} files and {results['similar_analysis']['patterns_found']} patterns")
|
126
|
+
|
127
|
+
# Step 2: Extract patterns from multiple carriers
|
128
|
+
print("\n2. Extracting patterns from similar carriers...")
|
129
|
+
patterns = extract_carrier_patterns(
|
130
|
+
similar_carriers=["fedex", "ups", "canadapost"],
|
131
|
+
pattern_type="all"
|
132
|
+
)
|
133
|
+
results["pattern_extraction"] = {
|
134
|
+
"success": "error" not in patterns,
|
135
|
+
"carriers_analyzed": len(patterns.get("analyzed_carriers", [])),
|
136
|
+
"best_practices": len(patterns.get("best_practices", [])),
|
137
|
+
"code_examples": len(patterns.get("code_examples", {}))
|
138
|
+
}
|
139
|
+
print(f"โ Analyzed {results['pattern_extraction']['carriers_analyzed']} carriers, found {results['pattern_extraction']['best_practices']} best practices")
|
140
|
+
|
141
|
+
# Step 3: Generate schemas
|
142
|
+
print("\n3. Generating schemas...")
|
143
|
+
rate_schema = generate_carrier_schema(
|
144
|
+
carrier_name="swiftship",
|
145
|
+
api_documentation=json.dumps(api_docs["rate_response"]["schema"]),
|
146
|
+
schema_type="rates"
|
147
|
+
)
|
148
|
+
results["schema_generation"] = {
|
149
|
+
"success": "error" not in rate_schema,
|
150
|
+
"classes_generated": len(rate_schema.get("classes", [])),
|
151
|
+
"imports_needed": len(rate_schema.get("imports", []))
|
152
|
+
}
|
153
|
+
print(f"โ Generated {results['schema_generation']['classes_generated']} classes with {results['schema_generation']['imports_needed']} imports")
|
154
|
+
|
155
|
+
# Step 4: Generate mappings
|
156
|
+
print("\n4. Generating mappings...")
|
157
|
+
mappings = generate_carrier_mappings(
|
158
|
+
carrier_name="swiftship",
|
159
|
+
api_endpoints={
|
160
|
+
"rates": "https://api.swiftship.com/v2/rates/quote",
|
161
|
+
"shipments": "https://api.swiftship.com/v2/shipments/create",
|
162
|
+
"tracking": "https://api.swiftship.com/v2/tracking/status"
|
163
|
+
},
|
164
|
+
operation_type="complete"
|
165
|
+
)
|
166
|
+
results["mapping_generation"] = {
|
167
|
+
"success": "error" not in mappings,
|
168
|
+
"mappings_generated": len(mappings.get("generated_mappings", {})),
|
169
|
+
"endpoints_covered": len(mappings.get("endpoints", {}))
|
170
|
+
}
|
171
|
+
print(f"โ Generated {results['mapping_generation']['mappings_generated']} mappings for {results['mapping_generation']['endpoints_covered']} endpoints")
|
172
|
+
|
173
|
+
# Step 5: Generate tests
|
174
|
+
print("\n5. Generating tests...")
|
175
|
+
test_data = {
|
176
|
+
"operations": ["rates", "shipments", "tracking"],
|
177
|
+
"test_addresses": {
|
178
|
+
"domestic": {"country": "US", "postal_code": "90210"},
|
179
|
+
"international": {"country": "CA", "postal_code": "M5V 3A1"}
|
180
|
+
},
|
181
|
+
"test_packages": [
|
182
|
+
{"weight": 5.0, "length": 10, "width": 8, "height": 6},
|
183
|
+
{"weight": 25.0, "length": 20, "width": 16, "height": 12}
|
184
|
+
]
|
185
|
+
}
|
186
|
+
tests = generate_integration_tests(
|
187
|
+
carrier_name="swiftship",
|
188
|
+
test_data=test_data,
|
189
|
+
test_type="complete"
|
190
|
+
)
|
191
|
+
results["test_generation"] = {
|
192
|
+
"success": "error" not in tests,
|
193
|
+
"test_categories": len(tests.get("generated_tests", {})),
|
194
|
+
"test_files": len(tests.get("test_files", []))
|
195
|
+
}
|
196
|
+
print(f"โ Generated {results['test_generation']['test_categories']} test categories")
|
197
|
+
|
198
|
+
# Step 6: Assemble complete integration
|
199
|
+
print("\n6. Assembling complete integration...")
|
200
|
+
integration = assemble_complete_integration(
|
201
|
+
carrier_name="swiftship",
|
202
|
+
integration_config=carrier_config
|
203
|
+
)
|
204
|
+
results["integration_assembly"] = {
|
205
|
+
"success": "error" not in integration and integration.get("integration_complete", False),
|
206
|
+
"files_generated": len(integration.get("generated_files", {})),
|
207
|
+
"next_steps": len(integration.get("next_steps", []))
|
208
|
+
}
|
209
|
+
print(f"โ Integration complete: {results['integration_assembly']['success']}")
|
210
|
+
print(f"โ Generated {results['integration_assembly']['files_generated']} file types")
|
211
|
+
|
212
|
+
return results
|
213
|
+
|
214
|
+
except Exception as e:
|
215
|
+
print(f"โ Real-world integration test failed: {e}")
|
216
|
+
return {"error": str(e)}
|
217
|
+
|
218
|
+
|
219
|
+
def evaluate_completion_percentage(results):
|
220
|
+
"""Evaluate how close we are to 95% completion."""
|
221
|
+
print("\n=== Completion Evaluation ===")
|
222
|
+
|
223
|
+
if "error" in results:
|
224
|
+
print(f"โ Integration failed: {results['error']}")
|
225
|
+
return 0
|
226
|
+
|
227
|
+
# Define completion criteria and weights
|
228
|
+
criteria = {
|
229
|
+
"similar_analysis": {"weight": 10, "max_score": 100},
|
230
|
+
"pattern_extraction": {"weight": 15, "max_score": 100},
|
231
|
+
"schema_generation": {"weight": 20, "max_score": 100},
|
232
|
+
"mapping_generation": {"weight": 25, "max_score": 100},
|
233
|
+
"test_generation": {"weight": 15, "max_score": 100},
|
234
|
+
"integration_assembly": {"weight": 15, "max_score": 100}
|
235
|
+
}
|
236
|
+
|
237
|
+
total_score = 0
|
238
|
+
max_possible = sum(c["weight"] for c in criteria.values())
|
239
|
+
|
240
|
+
for criterion, config in criteria.items():
|
241
|
+
if criterion in results:
|
242
|
+
result = results[criterion]
|
243
|
+
|
244
|
+
# Calculate success score for this criterion
|
245
|
+
if result["success"]:
|
246
|
+
if criterion == "similar_analysis":
|
247
|
+
score = min(100, (result["files_found"] / 400) * 100) # Expect ~400 files for major carriers
|
248
|
+
elif criterion == "pattern_extraction":
|
249
|
+
score = min(100, (result["best_practices"] / 10) * 50 + (result["code_examples"] / 5) * 50)
|
250
|
+
elif criterion == "schema_generation":
|
251
|
+
score = min(100, (result["classes_generated"] / 3) * 100) # Expect ~3 main classes
|
252
|
+
elif criterion == "mapping_generation":
|
253
|
+
score = min(100, (result["mappings_generated"] / 3) * 100) # rates, shipments, tracking
|
254
|
+
elif criterion == "test_generation":
|
255
|
+
score = min(100, (result["test_categories"] / 3) * 100) # unit, integration, fixtures
|
256
|
+
elif criterion == "integration_assembly":
|
257
|
+
score = 100 if result["success"] else 0
|
258
|
+
else:
|
259
|
+
score = 100
|
260
|
+
else:
|
261
|
+
score = 0
|
262
|
+
|
263
|
+
weighted_score = (score / 100) * config["weight"]
|
264
|
+
total_score += weighted_score
|
265
|
+
|
266
|
+
print(f"{criterion}: {score:.1f}% (weight: {config['weight']}%, contribution: {weighted_score:.1f}%)")
|
267
|
+
else:
|
268
|
+
print(f"{criterion}: 0% (missing)")
|
269
|
+
|
270
|
+
completion_percentage = (total_score / max_possible) * 100
|
271
|
+
print(f"\n๐ฏ Overall Completion: {completion_percentage:.1f}%")
|
272
|
+
|
273
|
+
if completion_percentage >= 95:
|
274
|
+
print("๐ Excellent! Ready for production use.")
|
275
|
+
elif completion_percentage >= 85:
|
276
|
+
print("โ
Good! Minor improvements needed.")
|
277
|
+
elif completion_percentage >= 70:
|
278
|
+
print("โ ๏ธ Decent progress, but needs significant improvements.")
|
279
|
+
else:
|
280
|
+
print("โ Major work needed to reach production readiness.")
|
281
|
+
|
282
|
+
return completion_percentage
|
283
|
+
|
284
|
+
|
285
|
+
def identify_improvement_areas(results, completion_percentage):
|
286
|
+
"""Identify specific areas that need improvement."""
|
287
|
+
print(f"\n=== Improvement Recommendations ===")
|
288
|
+
|
289
|
+
improvements = []
|
290
|
+
|
291
|
+
# Check each area and suggest improvements
|
292
|
+
if "similar_analysis" in results and results["similar_analysis"]["files_found"] < 300:
|
293
|
+
improvements.append("๐ Enhance connector analysis depth - currently analyzing fewer files than expected")
|
294
|
+
|
295
|
+
if "pattern_extraction" in results and results["pattern_extraction"]["best_practices"] < 5:
|
296
|
+
improvements.append("๐งฉ Improve pattern extraction - need more comprehensive best practice identification")
|
297
|
+
|
298
|
+
if "schema_generation" in results and results["schema_generation"]["classes_generated"] < 2:
|
299
|
+
improvements.append("๐ Enhance schema generation - should generate multiple related classes")
|
300
|
+
|
301
|
+
if "mapping_generation" in results and results["mapping_generation"]["mappings_generated"] < 3:
|
302
|
+
improvements.append("๐ Complete mapping generation - need all operation types (rates, shipments, tracking)")
|
303
|
+
|
304
|
+
if "test_generation" in results and results["test_generation"]["test_categories"] < 3:
|
305
|
+
improvements.append("๐งช Expand test coverage - need unit, integration, and fixture generation")
|
306
|
+
|
307
|
+
# Add priority improvements based on completion percentage
|
308
|
+
if completion_percentage < 95:
|
309
|
+
improvements.extend([
|
310
|
+
"๐ Implement actual file generation (currently just generates descriptions)",
|
311
|
+
"๐ง Add validation of generated code syntax and imports",
|
312
|
+
"๐ Enhance schema generation with actual API documentation parsing",
|
313
|
+
"๐ฏ Implement carrier-specific customizations based on API characteristics",
|
314
|
+
"๐ Add comprehensive error handling and validation",
|
315
|
+
"๐ Include performance optimization and caching",
|
316
|
+
"๐งฉ Add support for complex authentication methods (OAuth, certificates)",
|
317
|
+
"๐ Support for international shipping requirements",
|
318
|
+
"๐ Add real-time API testing and validation"
|
319
|
+
])
|
320
|
+
|
321
|
+
if improvements:
|
322
|
+
print("Priority improvements needed:")
|
323
|
+
for i, improvement in enumerate(improvements[:5], 1): # Show top 5
|
324
|
+
print(f"{i}. {improvement}")
|
325
|
+
else:
|
326
|
+
print("๐ No major improvements needed - ready for production!")
|
327
|
+
|
328
|
+
return improvements
|
329
|
+
|
330
|
+
|
331
|
+
def main():
|
332
|
+
"""Run the real-world integration test and evaluation."""
|
333
|
+
print("๐ Starting Real-World Integration Test")
|
334
|
+
print("=" * 60)
|
335
|
+
|
336
|
+
# Run the complete integration test
|
337
|
+
results = test_real_world_integration()
|
338
|
+
|
339
|
+
# Evaluate completion percentage
|
340
|
+
completion_percentage = evaluate_completion_percentage(results)
|
341
|
+
|
342
|
+
# Identify improvement areas
|
343
|
+
improvements = identify_improvement_areas(results, completion_percentage)
|
344
|
+
|
345
|
+
print(f"\n" + "=" * 60)
|
346
|
+
print(f"๐ FINAL ASSESSMENT: {completion_percentage:.1f}% Complete")
|
347
|
+
print(f"๐ฏ Target: 95% for production readiness")
|
348
|
+
print(f"๐ Gap: {max(0, 95 - completion_percentage):.1f}% remaining")
|
349
|
+
|
350
|
+
if completion_percentage >= 95:
|
351
|
+
print("๐ READY FOR PRODUCTION! ๐")
|
352
|
+
else:
|
353
|
+
print(f"โ ๏ธ Need {95 - completion_percentage:.1f}% more to reach production readiness")
|
354
|
+
|
355
|
+
return completion_percentage >= 95
|
356
|
+
|
357
|
+
|
358
|
+
if __name__ == "__main__":
|
359
|
+
success = main()
|
360
|
+
sys.exit(0 if success else 1)
|