mcp-souschef 2.0.1__tar.gz → 2.1.2__tar.gz

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 (30) hide show
  1. {mcp_souschef-2.0.1 → mcp_souschef-2.1.2}/PKG-INFO +427 -79
  2. {mcp_souschef-2.0.1 → mcp_souschef-2.1.2}/README.md +426 -78
  3. {mcp_souschef-2.0.1 → mcp_souschef-2.1.2}/pyproject.toml +4 -1
  4. mcp_souschef-2.1.2/souschef/__init__.py +17 -0
  5. mcp_souschef-2.1.2/souschef/assessment.py +1230 -0
  6. mcp_souschef-2.1.2/souschef/converters/__init__.py +23 -0
  7. mcp_souschef-2.1.2/souschef/converters/habitat.py +674 -0
  8. mcp_souschef-2.1.2/souschef/converters/playbook.py +1698 -0
  9. mcp_souschef-2.1.2/souschef/converters/resource.py +228 -0
  10. mcp_souschef-2.1.2/souschef/core/__init__.py +58 -0
  11. mcp_souschef-2.1.2/souschef/core/constants.py +145 -0
  12. mcp_souschef-2.1.2/souschef/core/path_utils.py +58 -0
  13. mcp_souschef-2.1.2/souschef/core/ruby_utils.py +39 -0
  14. mcp_souschef-2.1.2/souschef/core/validation.py +555 -0
  15. mcp_souschef-2.1.2/souschef/deployment.py +1594 -0
  16. mcp_souschef-2.1.2/souschef/filesystem/__init__.py +5 -0
  17. mcp_souschef-2.1.2/souschef/filesystem/operations.py +67 -0
  18. mcp_souschef-2.1.2/souschef/parsers/__init__.py +36 -0
  19. mcp_souschef-2.1.2/souschef/parsers/attributes.py +257 -0
  20. mcp_souschef-2.1.2/souschef/parsers/habitat.py +288 -0
  21. mcp_souschef-2.1.2/souschef/parsers/inspec.py +771 -0
  22. mcp_souschef-2.1.2/souschef/parsers/metadata.py +175 -0
  23. mcp_souschef-2.1.2/souschef/parsers/recipe.py +200 -0
  24. mcp_souschef-2.1.2/souschef/parsers/resource.py +170 -0
  25. mcp_souschef-2.1.2/souschef/parsers/template.py +342 -0
  26. mcp_souschef-2.1.2/souschef/server.py +2132 -0
  27. mcp_souschef-2.0.1/souschef/__init__.py +0 -0
  28. mcp_souschef-2.0.1/souschef/server.py +0 -8199
  29. {mcp_souschef-2.0.1 → mcp_souschef-2.1.2}/LICENSE +0 -0
  30. {mcp_souschef-2.0.1 → mcp_souschef-2.1.2}/souschef/cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-souschef
3
- Version: 2.0.1
3
+ Version: 2.1.2
4
4
  Summary: AI-powered MCP server for Chef to Ansible conversion
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -16,12 +16,12 @@ Requires-Dist: python-dotenv (>=1.2.1)
16
16
  Requires-Dist: zod (>=0.8.0)
17
17
  Description-Content-Type: text/markdown
18
18
 
19
- # Chef to Ansible migration - SousChef MCP 🍳
19
+ # Chef to Ansible migration - SousChef MCP
20
20
 
21
21
  An AI-powered MCP (Model Context Protocol) server that provides comprehensive Chef-to-Ansible migration capabilities for enterprise infrastructure transformation.
22
22
 
23
23
  [![PyPI version](https://img.shields.io/pypi/v/mcp-souschef.svg)](https://pypi.org/project/mcp-souschef/)
24
- [![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
24
+ [![Python Version](https://img.shields.io/badge/python-3.14%2B-blue.svg)](https://www.python.org/downloads/)
25
25
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
26
26
  [![Test Coverage](https://img.shields.io/badge/coverage-92%25-brightgreen.svg)](htmlcov/index.html)
27
27
  [![Code style: Ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
@@ -32,9 +32,24 @@ An AI-powered MCP (Model Context Protocol) server that provides comprehensive Ch
32
32
 
33
33
  ## Overview - Chef to Ansible features
34
34
 
35
- SousChef is a complete enterprise-grade migration platform with 34 MCP tools organized across 8 major capability areas to facilitate Chef-to-Ansible AWX/AAP migrations. From cookbook analysis to deployment pattern conversion, SousChef provides everything needed for a successful infrastructure automation migration.
35
+ SousChef is a complete enterprise-grade migration platform with 38 MCP tools organized across 9 major capability areas to facilitate Chef-to-Ansible AWX/AAP migrations. From cookbook analysis to deployment pattern conversion, including Chef Habitat to containerized deployments, SousChef provides everything needed for a successful infrastructure automation migration.
36
36
 
37
- ## 📦 Installation
37
+ ## Model Agnostic - Works with Any AI Model
38
+
39
+ **SousChef works with ANY AI model through the Model Context Protocol (MCP)**. The MCP architecture separates tools from models:
40
+
41
+ - **Red Hat AI** (Llama, IBM models)
42
+ - **Claude** (Anthropic)
43
+ - **GPT-4/GPT-3.5** (OpenAI)
44
+ - **GitHub Copilot** (Microsoft/OpenAI)
45
+ - **Local Models** (Ollama, llama.cpp, etc.)
46
+ - **Custom Enterprise Models**
47
+
48
+ **How it works:** You choose your AI model provider in your MCP client. SousChef provides the Chef/Ansible expertise through 38 specialized tools. The model calls these tools to help with your migration.
49
+
50
+ > See [config/CONFIGURATION.md](config/CONFIGURATION.md) for configuration examples with different model providers.
51
+
52
+ ## Installation
38
53
 
39
54
  ```bash
40
55
  # PyPI Installation
@@ -46,9 +61,9 @@ cd souschef
46
61
  poetry install
47
62
  ```
48
63
 
49
- > **📖 For detailed installation instructions, MCP setup, and configuration, see [Installation & Setup](#installation--setup)**
64
+ > **For detailed installation instructions, MCP setup, and configuration, see [Installation & Setup](#installation--setup)**
50
65
 
51
- ## 🚀 Core Capabilities
66
+ ## Core Capabilities
52
67
 
53
68
  ### 1. Chef Cookbook Analysis & Parsing
54
69
  Complete cookbook introspection and analysis tools:
@@ -59,7 +74,7 @@ Complete cookbook introspection and analysis tools:
59
74
  - **read_file** - Read cookbook files with error handling
60
75
  - **read_cookbook_metadata** - Parse metadata.rb files for dependencies and cookbook information
61
76
  - **parse_recipe** - Analyze Chef recipes and extract resources, actions, and properties
62
- - **parse_attributes** - Parse attribute files (default, override, normal) with precedence analysis
77
+ - **parse_attributes** - Parse attribute files with **advanced precedence resolution** (6 levels: default, force_default, normal, override, force_override, automatic)
63
78
  - **list_cookbook_structure** - Display complete cookbook directory hierarchy
64
79
 
65
80
  ### 2. Chef-to-Ansible Conversion Engine
@@ -67,6 +82,12 @@ Advanced resource-to-task conversion with intelligent module selection:
67
82
 
68
83
  - **convert_resource_to_task** - Transform individual Chef resources to Ansible tasks
69
84
  - **generate_playbook_from_recipe** - Generate complete Ansible playbooks from Chef recipes
85
+ - **Enhanced Guard Handling** - Convert complex Chef guards to Ansible when/unless conditions
86
+ - Array-based guards: `only_if ['condition1', 'condition2']`
87
+ - Lambda/proc syntax: `only_if { ::File.exist?('/path') }`
88
+ - Do-end blocks: `not_if do ... end`
89
+ - Multiple guard types per resource with proper AND/OR logic
90
+ - Platform checks, node attributes, file/directory existence, and command execution
70
91
 
71
92
  ### 3. Chef Search & Inventory Integration
72
93
  Convert Chef search patterns to dynamic Ansible inventory:
@@ -104,19 +125,69 @@ Enterprise AWX/AAP configuration generation:
104
125
  - **generate_awx_project_from_cookbooks** - Generate AWX projects from cookbook collections
105
126
  - **generate_awx_inventory_source_from_chef** - Create dynamic inventory sources from Chef server
106
127
 
107
- ### 8. Advanced Deployment Patterns & Migration Assessment
128
+ ### 8. Chef Habitat to Container Conversion
129
+ Modernize Habitat applications to containerized deployments:
130
+
131
+ - **parse_habitat_plan** - Parse Chef Habitat plan files (plan.sh) and extract package metadata, dependencies, build/install hooks, and service configuration
132
+ - **convert_habitat_to_dockerfile** - Convert Chef Habitat plans to production-ready Dockerfiles with security validation
133
+ - **generate_compose_from_habitat** - Generate docker-compose.yml from multiple Habitat plans for multi-service deployments
134
+
135
+ ### 9. Advanced Deployment Patterns & Migration Assessment
108
136
  Modern deployment strategies and migration planning:
109
137
 
110
138
  - **convert_chef_deployment_to_ansible_strategy** - Convert deployment recipes to Ansible strategies
111
139
  - **generate_blue_green_deployment_playbook** - Create blue/green deployment playbooks
112
140
  - **generate_canary_deployment_strategy** - Generate canary deployment configurations
141
+
142
+ ### 10. Conversion Validation Framework
143
+ Comprehensive validation of Chef-to-Ansible conversions:
144
+
145
+ - **validate_conversion** - Validate conversions across multiple dimensions
146
+ - **Syntax Validation**: YAML, Jinja2, Python syntax checking
147
+ - **Semantic Validation**: Logic equivalence, variable usage, resource dependencies
148
+ - **Best Practice Checks**: Naming conventions, idempotency, task organization
149
+ - **Security Validation**: Privilege escalation patterns, sensitive data handling
150
+ - **Performance Recommendations**: Efficiency suggestions and optimizations
151
+
152
+ #### Validation Levels
153
+ - **ERROR**: Critical issues that will prevent execution
154
+ - **WARNING**: Potential problems or anti-patterns that may cause issues
155
+ - **INFO**: Suggestions for improvements and best practices
156
+
157
+ #### Validation Categories
158
+ - **Syntax**: Code structure and syntax correctness
159
+ - **Semantic**: Logical equivalence and meaning preservation
160
+ - **Best Practice**: Ansible community standards and patterns
161
+ - **Security**: Security considerations and recommendations
162
+ - **Performance**: Efficiency and optimization suggestions
163
+
164
+ #### Example Usage
165
+
166
+ ```python
167
+ # Validate a resource conversion
168
+ validate_conversion(
169
+ conversion_type="resource",
170
+ result_content="""- name: Install nginx
171
+ ansible.builtin.package:
172
+ name: "nginx"
173
+ state: present
174
+ """,
175
+ output_format="text" # Options: text, json, summary
176
+ )
177
+ ```
178
+
179
+ Output formats:
180
+ - **text**: Detailed report with all findings grouped by severity
181
+ - **json**: Structured JSON for programmatic processing
182
+ - **summary**: Quick overview with counts only
183
+
113
184
  - **analyze_chef_application_patterns** - Identify application deployment patterns
114
185
  - **assess_chef_migration_complexity** - Comprehensive migration complexity assessment
115
186
  - **generate_migration_plan** - Create detailed migration execution plans
116
187
  - **analyze_cookbook_dependencies** - Analyze dependencies and migration order
117
188
  - **generate_migration_report** - Generate executive and technical migration reports
118
189
 
119
- ## 🎯 Migration Workflow
190
+ ## Migration Workflow
120
191
 
121
192
  ### Phase 1: Discovery & Assessment
122
193
  ```bash
@@ -154,7 +225,19 @@ generate_awx_workflow_from_chef_runlist \"recipe[app::deploy]\" workflow_name
154
225
  generate_awx_inventory_source_from_chef https://chef.example.com production web_servers
155
226
  ```
156
227
 
157
- ### Phase 4: Validation & Testing
228
+ ### Phase 4: Habitat to Container Migration
229
+ ```bash
230
+ # Parse Habitat plan
231
+ parse_habitat_plan /path/to/plan.sh
232
+
233
+ # Convert to Dockerfile
234
+ convert_habitat_to_dockerfile /path/to/plan.sh ubuntu:22.04
235
+
236
+ # Generate docker-compose for multiple services
237
+ generate_compose_from_habitat "/path/to/plan1.sh,/path/to/plan2.sh" my_network
238
+ ```
239
+
240
+ ### Phase 5: Validation & Testing
158
241
  ```bash
159
242
  # Generate InSpec validation
160
243
  generate_inspec_from_recipe /path/to/recipe.rb
@@ -163,7 +246,7 @@ generate_inspec_from_recipe /path/to/recipe.rb
163
246
  convert_inspec_to_test /path/to/inspec_profile testinfra
164
247
  ```
165
248
 
166
- ## 📊 Enterprise Features
249
+ ## Enterprise Features
167
250
 
168
251
  ### Migration Assessment & Reporting
169
252
  - **Complexity Analysis**: Automated assessment of migration effort and risk factors
@@ -176,6 +259,7 @@ convert_inspec_to_test /path/to/inspec_profile testinfra
176
259
  - **Canary Releases**: Gradual rollout configurations
177
260
  - **Application Patterns**: Modern containerized and cloud-native deployment patterns
178
261
  - **Rollback Strategies**: Automated failure recovery procedures
262
+ - **Habitat to Container**: Convert Chef Habitat plans to Docker and Docker Compose configurations
179
263
 
180
264
  ### Enterprise Integration
181
265
  - **AWX/AAP Ready**: Native Ansible Automation Platform integration
@@ -183,7 +267,7 @@ convert_inspec_to_test /path/to/inspec_profile testinfra
183
267
  - **Secrets Management**: Secure data bag to Vault conversion
184
268
  - **Multi-Environment**: Production-ready inventory and variable management
185
269
 
186
- ## 🛠️ Installation & Setup
270
+ ## Installation & Setup
187
271
 
188
272
  ### Prerequisites
189
273
  - Python 3.14+
@@ -197,23 +281,25 @@ convert_inspec_to_test /path/to/inspec_profile testinfra
197
281
  pip install mcp-souschef
198
282
  ```
199
283
 
200
- 2. **Configure MCP Client**:
284
+ 2. **Configure Your MCP Client**:
285
+
286
+ Use the pre-configured files in the `config/` directory for quick setup with Claude Desktop, VS Code Copilot, or other MCP clients.
201
287
 
202
- **🎯 Quick Setup - Use Pre-configured Files:**
203
288
  ```bash
204
- # Claude Desktop (macOS)
289
+ # Example: Claude Desktop (macOS)
205
290
  cp config/claude-desktop.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
206
-
207
- # VS Code Copilot (macOS/Linux)
208
- mkdir -p ~/.config/Code/User/globalStorage/github.copilot-chat
209
- cp config/vscode-copilot.json ~/.config/Code/User/globalStorage/github.copilot-chat/mcp.json
210
291
  ```
211
292
 
212
- See [config/README.md](config/README.md) for detailed setup instructions, development configs, and troubleshooting.
293
+ ** See [config/CONFIGURATION.md](config/CONFIGURATION.md) for:**
294
+ - Platform-specific setup (macOS/Linux/Windows)
295
+ - Model provider configurations (Red Hat AI, OpenAI, local models)
296
+ - Development setup
297
+ - Troubleshooting
213
298
 
214
- 3. **Start using SousChef**:
215
- - **Claude Desktop**: Restart Claude, then ask: "What tools does souschef provide?"
216
- - **VS Code Copilot**: Reload window, then use: `@souschef analyze this cookbook`
299
+ 3. **Start Using SousChef**:
300
+ - Restart your MCP client
301
+ - Ask: "What Chef migration tools are available?"
302
+ - Begin analyzing your cookbooks!
217
303
 
218
304
  ### Command Line Interface (CLI)
219
305
 
@@ -288,28 +374,31 @@ poetry update # All packages
288
374
  ```
289
375
 
290
376
  **Automated Systems:**
291
- -Pre-commit hooks auto-update `poetry.lock` when `pyproject.toml` changes
292
- -CI validates lock file on every PR
293
- -Dependabot sends weekly dependency updates
377
+ - Pre-commit hooks auto-update `poetry.lock` when `pyproject.toml` changes
378
+ - CI validates lock file on every PR
379
+ - Dependabot sends weekly dependency updates
294
380
 
295
381
  See [CONTRIBUTING.md](CONTRIBUTING.md#-managing-dependencies) for detailed dependency management guide.
296
382
 
297
- ## 🏗️ Architecture & Design
383
+ ## Architecture & Design
298
384
 
299
385
  ### MCP Protocol Integration
300
386
  SousChef leverages the Model Context Protocol (MCP) to provide seamless integration with AI assistants and development environments:
301
387
 
302
- - **34 Specialized Tools**: Each migration capability exposed as dedicated MCP tool
388
+ - **38 Specialized Tools**: Each migration capability exposed as dedicated MCP tool
303
389
  - **Type-Safe Interfaces**: Full Python type hints for reliable AI interactions
304
390
  - **Comprehensive Error Handling**: Graceful degradation and helpful error messages
305
391
  - **Streaming Support**: Efficient handling of large cookbook conversions
306
392
 
307
393
  ### Testing Strategy
308
- Following enterprise-grade testing standards:
309
-
310
- - **Unit Tests**: Mock-based testing for individual functions (tests/test_server.py)
311
- - **Integration Tests**: Real cookbook testing with fixtures (tests/test_integration.py)
312
- - **Property-Based Tests**: Hypothesis fuzz testing for edge cases (tests/test_property_based.py)
394
+ Following enterprise-grade testing standards with comprehensive test coverage:
395
+
396
+ - **Unit Tests**: Mock-based testing for individual functions (test_server.py, test_cli.py, test_mcp.py)
397
+ - **Integration Tests**: Real cookbook testing with fixtures (test_integration.py, test_integration_accuracy.py)
398
+ - **Property-Based Tests**: Hypothesis fuzz testing for edge cases (test_property_based.py)
399
+ - **Specialized Tests**: Enhanced guards (test_enhanced_guards.py), error handling (test_error_paths.py, test_error_recovery.py), real-world fixtures (test_real_world_fixtures.py)
400
+ - **Performance Tests**: Benchmarking and optimization validation (test_performance.py)
401
+ - **Snapshot Tests**: Regression testing for output stability (test_snapshots.py)
313
402
  - **92% Coverage**: Comprehensive test coverage exceeding the 90% target for production readiness
314
403
 
315
404
  ### Quality Assurance
@@ -318,7 +407,7 @@ Following enterprise-grade testing standards:
318
407
  - **Automated Testing**: CI/CD pipeline with comprehensive test suites
319
408
  - **Documentation**: Detailed docstrings and usage examples
320
409
 
321
- ## 📚 Documentation
410
+ ## Documentation
322
411
 
323
412
  ### Tool Reference
324
413
  Each MCP tool includes comprehensive documentation:
@@ -346,36 +435,38 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for:
346
435
 
347
436
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
348
437
 
349
- ## 🚀 Roadmap
350
-
351
- ### Completed
352
- -Complete Chef cookbook parsing (recipes, attributes, metadata, templates)
353
- -InSpec profile parsing and conversion to Testinfra/Ansible tests
354
- -Chef resource to Ansible task conversion with module mapping
355
- -Data bags to Ansible Vault conversion
356
- -Chef environments to Ansible inventory conversion
357
- -Chef search patterns to dynamic inventory conversion
358
- -AWX/AAP job templates, workflows, and project generation
359
- -Blue/green and canary deployment pattern generation
360
- -Migration complexity assessment and planning tools
361
- -Comprehensive testing suite (unit, integration, property-based)
362
- -Command-line interface (CLI) for standalone usage
363
-
364
- ### In Progress 🔄
365
- - 🔄 Enhanced error handling and user experience improvements
366
- - 🔄 Documentation website and interactive examples
367
- - 🔄 Performance optimizations for large-scale enterprise migrations
368
- - 🔄 Technical debt reduction (15 functions tracked in [GitHub Issues](https://github.com/kpeacocke/souschef/issues?q=is%3Aissue+is%3Aopen+label%3Atechnical-debt))
438
+ ## Roadmap
439
+
440
+ ### Completed
441
+ - Complete Chef cookbook parsing (recipes, attributes, metadata, templates)
442
+ - InSpec profile parsing and conversion to Testinfra/Ansible tests
443
+ - Chef resource to Ansible task conversion with module mapping
444
+ - Data bags to Ansible Vault conversion
445
+ - Chef environments to Ansible inventory conversion
446
+ - Chef search patterns to dynamic inventory conversion
447
+ - AWX/AAP job templates, workflows, and project generation
448
+ - Blue/green and canary deployment pattern generation
449
+ - Migration complexity assessment and planning tools
450
+ - Comprehensive testing suite (unit, integration, property-based)
451
+ - Command-line interface (CLI) for standalone usage
452
+ - Enhanced Chef guard handling (arrays, lambda syntax, complex nested conditions)
453
+ - Advanced attribute precedence resolution (6 levels with conflict detection)
454
+ - Automated release management with Release Please
455
+ - Automated branch cleanup for release PRs
456
+ - Automated conversion validation and testing framework
457
+ - Chef Habitat to containerized deployment conversion (parse_habitat_plan, convert_habitat_to_dockerfile, generate_compose_from_habitat)
458
+
459
+ ### In Progress
460
+ - Enhanced error handling and user experience improvements
461
+ - Documentation website and interactive examples
462
+ - Performance optimizations for large-scale enterprise migrations
463
+ - Technical debt reduction (15 functions tracked in [GitHub Issues](https://github.com/kpeacocke/souschef/issues?q=is%3Aissue+is%3Aopen+label%3Atechnical-debt))
369
464
 
370
465
  ### Planned 📅
371
- - 📅 Chef Habitat to containerized deployment conversion
372
466
  - 📅 Integration with additional test frameworks (ServerSpec, Goss)
373
467
  - 📅 Visual migration planning and dependency mapping interface
374
468
  - 📅 Terraform provider for infrastructure state management
375
469
  - 📅 Jenkins/GitLab CI pipeline generation
376
- - 📅 Advanced Chef guard handling (only_if, not_if conditions)
377
- - 📅 Complex attribute precedence and merging logic
378
- - 📅 Conversion validation and testing framework
379
470
 
380
471
  ## 🙋‍♀️ Support & Community
381
472
 
@@ -385,7 +476,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
385
476
 
386
477
  ---
387
478
 
388
- **SousChef** - *Transforming infrastructure automation, one recipe at a time.* 🍳✨
479
+ **SousChef** - *Transforming infrastructure automation, one recipe at a time.*
389
480
  desc 'Ensure package nginx is properly configured'
390
481
  impact 1.0
391
482
 
@@ -554,17 +645,59 @@ parse_recipe("/path/to/cookbook/recipes/default.rb")
554
645
  # Action: install
555
646
  ```
556
647
 
557
- #### `parse_attributes(path: str)`
558
- Parse a Chef attributes file and extract attribute definitions.
648
+ #### `parse_attributes(path: str, resolve_precedence: bool = True)`
649
+ Parse a Chef attributes file and extract attribute definitions with precedence analysis.
650
+
651
+ **Chef Attribute Precedence** (lowest to highest):
652
+ 1. `default` - Normal default value
653
+ 2. `force_default` - Forced default, higher than regular default
654
+ 3. `normal` - Normal attribute set by cookbook
655
+ 4. `override` - Override values
656
+ 5. `force_override` - Forced override, cannot be overridden
657
+ 6. `automatic` - Automatically detected by Ohai (highest precedence)
658
+
659
+ When multiple attributes with the same path exist at different precedence levels, the highest precedence wins. The tool automatically resolves conflicts and reports which values were overridden.
660
+
661
+ **Parameters:**
662
+ - `path`: Path to the attributes (.rb) file
663
+ - `resolve_precedence`: If True (default), resolves conflicts and shows only winning values. If False, shows all attributes.
559
664
 
560
665
  **Example:**
561
666
  ```python
667
+ # With precedence resolution (default)
562
668
  parse_attributes("/path/to/cookbook/attributes/default.rb")
563
669
  # Returns:
670
+ # Resolved Attributes (with precedence):
671
+ # ==================================================
672
+ #
673
+ # Attribute: nginx.port
674
+ # Value: 443
675
+ # Precedence: force_override (level 5)
676
+ # Overridden values: default=80, normal=8080
677
+ #
678
+ # Attribute: nginx.ssl_port
679
+ # Value: 443
680
+ # Precedence: default (level 1)
681
+ #
682
+ # ==================================================
683
+ # Total attributes: 2
684
+ # Attributes with precedence conflicts: 1
685
+
686
+ # Without precedence resolution (show all)
687
+ parse_attributes("/path/to/cookbook/attributes/default.rb", resolve_precedence=False)
688
+ # Returns:
564
689
  # default[nginx.port] = 80
690
+ # normal[nginx.port] = 8080
691
+ # force_override[nginx.port] = 443
565
692
  # default[nginx.ssl_port] = 443
566
693
  ```
567
694
 
695
+ **Use Cases:**
696
+ - Understanding attribute conflicts in complex cookbooks
697
+ - Debugging which attributes will actually be applied
698
+ - Planning attribute migrations to Ansible variables
699
+ - Identifying force_override attributes that need special handling
700
+
568
701
  #### `list_cookbook_structure(path: str)`
569
702
  List the structure of a Chef cookbook directory.
570
703
 
@@ -700,6 +833,207 @@ convert_resource_to_task("template", "/etc/nginx/nginx.conf.erb", "create")
700
833
  - `group` → `ansible.builtin.group`
701
834
  - And more...
702
835
 
836
+ #### `parse_habitat_plan(plan_path: str)`
837
+ Parse a Chef Habitat plan file (plan.sh) and extract package metadata, dependencies, build/install hooks, and service configuration.
838
+
839
+ **Example:**
840
+ ```python
841
+ parse_habitat_plan("/path/to/habitat/plan.sh")
842
+ # Returns JSON with:
843
+ # {
844
+ # "package": {
845
+ # "name": "nginx",
846
+ # "origin": "core",
847
+ # "version": "1.25.3",
848
+ # "maintainer": "The Habitat Maintainers",
849
+ # "description": "High-performance HTTP server"
850
+ # },
851
+ # "dependencies": {
852
+ # "build": ["core/gcc", "core/make"],
853
+ # "runtime": ["core/glibc", "core/openssl"]
854
+ # },
855
+ # "ports": [
856
+ # {"name": "http", "value": "http.port"},
857
+ # {"name": "https", "value": "http.ssl_port"}
858
+ # ],
859
+ # "binds": [
860
+ # {"name": "database", "value": "postgresql.default"}
861
+ # ],
862
+ # "service": {
863
+ # "run": "nginx -g 'daemon off;'",
864
+ # "user": "nginx"
865
+ # },
866
+ # "callbacks": {
867
+ # "do_build": "./configure --prefix=/usr/local\nmake",
868
+ # "do_install": "make install",
869
+ # "do_init": "mkdir -p /var/lib/nginx"
870
+ # }
871
+ # }
872
+ ```
873
+
874
+ **Extracted Information:**
875
+ - **Package metadata**: name, origin, version, maintainer, description
876
+ - **Dependencies**: Build-time and runtime package dependencies
877
+ - **Ports**: Exported port configurations for service discovery
878
+ - **Binds**: Service bindings to other Habitat services
879
+ - **Service configuration**: Run command, user, and initialization scripts
880
+ - **Build callbacks**: do_build, do_install, do_init, and other lifecycle hooks
881
+
882
+ **Use Cases:**
883
+ - Understanding Habitat application structure before containerization
884
+ - Extracting dependencies for Docker base image selection
885
+ - Planning port mappings for docker-compose configurations
886
+ - Analyzing service dependencies and orchestration needs
887
+
888
+ #### `convert_habitat_to_dockerfile(plan_path: str, base_image: str = "ubuntu:22.04")`
889
+ Convert a Chef Habitat plan to a production-ready Dockerfile with security validation.
890
+
891
+ **Example:**
892
+ ```python
893
+ convert_habitat_to_dockerfile("/path/to/habitat/plan.sh", "ubuntu:22.04")
894
+ # Returns:
895
+ # # Dockerfile generated from Habitat plan
896
+ # # Original plan: plan.sh
897
+ # # Package: core/nginx
898
+ # # Version: 1.25.3
899
+ #
900
+ # FROM ubuntu:22.04
901
+ #
902
+ # LABEL maintainer="The Habitat Maintainers"
903
+ # LABEL version="1.25.3"
904
+ #
905
+ # # Install dependencies
906
+ # RUN apt-get update && apt-get install -y --no-install-recommends \
907
+ # gcc \
908
+ # make \
909
+ # libssl-dev \
910
+ # && rm -rf /var/lib/apt/lists/*
911
+ #
912
+ # # Build steps
913
+ # WORKDIR /usr/local/src
914
+ # RUN ./configure --prefix=/usr/local && \
915
+ # make
916
+ #
917
+ # # Install steps
918
+ # RUN make install
919
+ #
920
+ # # Initialization steps
921
+ # RUN mkdir -p /var/lib/nginx
922
+ #
923
+ # # Runtime configuration
924
+ # EXPOSE 80
925
+ # EXPOSE 443
926
+ # USER nginx
927
+ # WORKDIR /usr/local
928
+ #
929
+ # CMD ["nginx", "-g", "daemon off;"]
930
+ ```
931
+
932
+ **Parameters:**
933
+ - `plan_path`: Path to the Habitat plan.sh file
934
+ - `base_image`: Docker base image (default: ubuntu:22.04). Validated for security
935
+
936
+ **Features:**
937
+ - **Dependency mapping**: Converts Habitat dependencies to apt packages
938
+ - **Build optimization**: Multi-stage builds when applicable
939
+ - **Security scanning**: Detects dangerous patterns (curl|sh, eval, etc.)
940
+ - **Metadata preservation**: LABEL instructions for package info
941
+ - **User configuration**: Non-root user setup when specified
942
+ - **Port exposure**: Automatic EXPOSE directives from plan ports
943
+
944
+ **Security Warnings:**
945
+ The tool processes shell commands from Habitat plans and includes them in the Dockerfile. Only use with trusted Habitat plans from known sources. Review generated Dockerfiles before building images.
946
+
947
+ #### `generate_compose_from_habitat(plan_paths: str, network_name: str = "habitat_net")`
948
+ Generate docker-compose.yml from multiple Habitat plans for multi-service deployments.
949
+
950
+ **Example:**
951
+ ```python
952
+ # Single service
953
+ generate_compose_from_habitat("/path/to/nginx/plan.sh", "myapp_network")
954
+ # Returns:
955
+ # version: '3.8'
956
+ # services:
957
+ # nginx:
958
+ # build:
959
+ # context: .
960
+ # dockerfile: Dockerfile.nginx
961
+ # container_name: nginx
962
+ # ports:
963
+ # - "80:80"
964
+ # - "443:443"
965
+ # environment:
966
+ # - HTTP=80
967
+ # - HTTPS=443
968
+ # networks:
969
+ # - myapp_network
970
+ #
971
+ # networks:
972
+ # myapp_network:
973
+ # driver: bridge
974
+
975
+ # Multiple services with dependencies
976
+ generate_compose_from_habitat(
977
+ "/path/to/backend/plan.sh,/path/to/postgres/plan.sh",
978
+ "app_network"
979
+ )
980
+ # Returns:
981
+ # version: '3.8'
982
+ # services:
983
+ # backend:
984
+ # build:
985
+ # context: .
986
+ # dockerfile: Dockerfile.backend
987
+ # container_name: backend
988
+ # ports:
989
+ # - "8080:8080"
990
+ # environment:
991
+ # - PORT=8080
992
+ # depends_on:
993
+ # - postgres
994
+ # networks:
995
+ # - app_network
996
+ #
997
+ # postgres:
998
+ # build:
999
+ # context: .
1000
+ # dockerfile: Dockerfile.postgres
1001
+ # container_name: postgres
1002
+ # ports:
1003
+ # - "5432:5432"
1004
+ # environment:
1005
+ # - POSTGRESQL=5432
1006
+ # volumes:
1007
+ # - postgres_data:/var/lib/app
1008
+ # networks:
1009
+ # - app_network
1010
+ #
1011
+ # networks:
1012
+ # app_network:
1013
+ # driver: bridge
1014
+ #
1015
+ # volumes:
1016
+ # postgres_data:
1017
+ ```
1018
+
1019
+ **Parameters:**
1020
+ - `plan_paths`: Comma-separated paths to plan.sh files for multiple services
1021
+ - `network_name`: Docker network name for service communication (default: habitat_net)
1022
+
1023
+ **Features:**
1024
+ - **Multi-service orchestration**: Combines multiple Habitat plans into one compose file
1025
+ - **Automatic dependencies**: Creates depends_on from Habitat service binds
1026
+ - **Volume detection**: Identifies services needing persistent storage from do_init callbacks
1027
+ - **Network isolation**: Configures bridge networks for service communication
1028
+ - **Port management**: Maps ports from Habitat exports to Docker compose
1029
+ - **Environment variables**: Generates environment configuration from port definitions
1030
+
1031
+ **Use Cases:**
1032
+ - Converting multi-service Habitat applications to Docker Compose
1033
+ - Creating development environments from production Habitat plans
1034
+ - Simplifying container orchestration for local testing
1035
+ - Migration path from Habitat to Kubernetes (via docker-compose)
1036
+
703
1037
  ## Development
704
1038
 
705
1039
  ### Project Structure
@@ -760,14 +1094,19 @@ poetry run pytest
760
1094
  # Run with coverage report
761
1095
  poetry run pytest --cov=souschef --cov-report=term-missing --cov-report=html
762
1096
 
763
- # Run only unit tests (mocked)
764
- poetry run pytest tests/test_server.py
765
-
766
- # Run only integration tests (real files)
767
- poetry run pytest tests/test_integration.py
768
-
769
- # Run property-based tests
770
- poetry run pytest tests/test_property_based.py
1097
+ # Run specific test suites
1098
+ poetry run pytest tests/test_server.py # Core unit tests
1099
+ poetry run pytest tests/test_cli.py # CLI tests
1100
+ poetry run pytest tests/test_mcp.py # MCP protocol tests
1101
+ poetry run pytest tests/test_integration.py # Integration tests
1102
+ poetry run pytest tests/test_integration_accuracy.py # Accuracy validation
1103
+ poetry run pytest tests/test_enhanced_guards.py # Guard conversion tests
1104
+ poetry run pytest tests/test_error_paths.py # Error handling
1105
+ poetry run pytest tests/test_error_recovery.py # Error recovery
1106
+ poetry run pytest tests/test_real_world_fixtures.py # Real-world cookbooks
1107
+ poetry run pytest tests/test_property_based.py # Hypothesis fuzz tests
1108
+ poetry run pytest tests/test_performance.py # Performance benchmarks
1109
+ poetry run pytest tests/test_snapshots.py # Snapshot regression tests
771
1110
 
772
1111
  # Run with benchmarks
773
1112
  poetry run pytest --benchmark-only
@@ -780,28 +1119,37 @@ poetry run mypy souschef # Type checking
780
1119
 
781
1120
  ### Test Types
782
1121
 
783
- The project includes multiple types of tests:
1122
+ The project includes comprehensive test coverage across multiple dimensions:
784
1123
 
785
- 1. **Unit Tests** (`test_server.py`)
1124
+ 1. **Unit Tests** (`test_server.py`, `test_cli.py`, `test_mcp.py`)
786
1125
  - Mock-based tests for individual functions
787
1126
  - Test error handling and edge cases
788
1127
  - Fast execution, isolated from filesystem
1128
+ - MCP protocol compliance testing
789
1129
 
790
- 2. **Integration Tests** (`test_integration.py`)
1130
+ 2. **Integration Tests** (`test_integration.py`, `test_integration_accuracy.py`)
791
1131
  - Real file operations with test fixtures
792
1132
  - Validate parsing with actual Chef cookbook files
793
1133
  - Parameterized tests for various scenarios
794
- - Performance benchmarks with pytest-benchmark
1134
+ - Accuracy validation for conversions
795
1135
 
796
1136
  3. **Property-Based Tests** (`test_property_based.py`)
797
1137
  - Uses Hypothesis for fuzz testing
798
1138
  - Generates random inputs to find edge cases
799
1139
  - Ensures functions handle any input gracefully
800
1140
 
801
- 4. **Test Fixtures**
802
- - Sample Chef cookbook in `tests/fixtures/sample_cookbook/`
803
- - Real-world metadata, recipes, and attributes
804
- - Used for integration testing
1141
+ 4. **Specialized Test Suites**
1142
+ - **Enhanced Guards** (`test_enhanced_guards.py`): Complex guard condition conversion
1143
+ - **Error Handling** (`test_error_paths.py`, `test_error_recovery.py`): Comprehensive error scenarios
1144
+ - **Real-World Fixtures** (`test_real_world_fixtures.py`): Production cookbook patterns
1145
+ - **Performance** (`test_performance.py`): Benchmarking and optimization
1146
+ - **Snapshots** (`test_snapshots.py`): Regression testing for output stability
1147
+
1148
+ 5. **Test Fixtures**
1149
+ - Sample Chef cookbooks in `tests/fixtures/`
1150
+ - Multiple cookbook types: apache2, docker, mysql, nodejs, legacy Chef 12, Habitat plans
1151
+ - Real-world metadata, recipes, attributes, and resources
1152
+ - Used across integration and accuracy testing
805
1153
 
806
1154
  ### Test Coverage
807
1155
 
@@ -845,5 +1193,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
845
1193
 
846
1194
  ---
847
1195
 
848
- **SousChef** - *Ansible automation, one recipe at a time.* 🍳✨
1196
+ **SousChef** - *Ansible automation, one recipe at a time.*
849
1197