nlp2cmd 0.1.0__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 (74) hide show
  1. nlp2cmd-0.1.0/.gitignore +163 -0
  2. nlp2cmd-0.1.0/LICENSE +21 -0
  3. nlp2cmd-0.1.0/PKG-INFO +505 -0
  4. nlp2cmd-0.1.0/README.md +425 -0
  5. nlp2cmd-0.1.0/docs/README.md +127 -0
  6. nlp2cmd-0.1.0/docs/api/README.md +465 -0
  7. nlp2cmd-0.1.0/docs/guides/user-guide.md +468 -0
  8. nlp2cmd-0.1.0/pyproject.toml +182 -0
  9. nlp2cmd-0.1.0/src/nlp2cmd/__init__.py +137 -0
  10. nlp2cmd-0.1.0/src/nlp2cmd/adapters/__init__.py +64 -0
  11. nlp2cmd-0.1.0/src/nlp2cmd/adapters/base.py +176 -0
  12. nlp2cmd-0.1.0/src/nlp2cmd/adapters/docker.py +584 -0
  13. nlp2cmd-0.1.0/src/nlp2cmd/adapters/dql.py +431 -0
  14. nlp2cmd-0.1.0/src/nlp2cmd/adapters/kubernetes.py +684 -0
  15. nlp2cmd-0.1.0/src/nlp2cmd/adapters/shell.py +936 -0
  16. nlp2cmd-0.1.0/src/nlp2cmd/adapters/sql.py +478 -0
  17. nlp2cmd-0.1.0/src/nlp2cmd/aggregator/__init__.py +383 -0
  18. nlp2cmd-0.1.0/src/nlp2cmd/cli/__init__.py +5 -0
  19. nlp2cmd-0.1.0/src/nlp2cmd/cli/main.py +604 -0
  20. nlp2cmd-0.1.0/src/nlp2cmd/core.py +639 -0
  21. nlp2cmd-0.1.0/src/nlp2cmd/environment/__init__.py +518 -0
  22. nlp2cmd-0.1.0/src/nlp2cmd/executor/__init__.py +678 -0
  23. nlp2cmd-0.1.0/src/nlp2cmd/feedback/__init__.py +522 -0
  24. nlp2cmd-0.1.0/src/nlp2cmd/generation/__init__.py +154 -0
  25. nlp2cmd-0.1.0/src/nlp2cmd/generation/hybrid.py +377 -0
  26. nlp2cmd-0.1.0/src/nlp2cmd/generation/keywords.py +455 -0
  27. nlp2cmd-0.1.0/src/nlp2cmd/generation/llm_multi.py +267 -0
  28. nlp2cmd-0.1.0/src/nlp2cmd/generation/llm_simple.py +367 -0
  29. nlp2cmd-0.1.0/src/nlp2cmd/generation/pipeline.py +328 -0
  30. nlp2cmd-0.1.0/src/nlp2cmd/generation/regex.py +432 -0
  31. nlp2cmd-0.1.0/src/nlp2cmd/generation/structured.py +371 -0
  32. nlp2cmd-0.1.0/src/nlp2cmd/generation/templates.py +805 -0
  33. nlp2cmd-0.1.0/src/nlp2cmd/generation/thermodynamic.py +874 -0
  34. nlp2cmd-0.1.0/src/nlp2cmd/generation/validating.py +297 -0
  35. nlp2cmd-0.1.0/src/nlp2cmd/planner/__init__.py +419 -0
  36. nlp2cmd-0.1.0/src/nlp2cmd/registry/__init__.py +642 -0
  37. nlp2cmd-0.1.0/src/nlp2cmd/router/__init__.py +290 -0
  38. nlp2cmd-0.1.0/src/nlp2cmd/schemas/__init__.py +595 -0
  39. nlp2cmd-0.1.0/src/nlp2cmd/thermodynamic/__init__.py +565 -0
  40. nlp2cmd-0.1.0/src/nlp2cmd/thermodynamic/energy_models.py +462 -0
  41. nlp2cmd-0.1.0/src/nlp2cmd/validators/__init__.py +325 -0
  42. nlp2cmd-0.1.0/tests/__init__.py +1 -0
  43. nlp2cmd-0.1.0/tests/conftest.py +289 -0
  44. nlp2cmd-0.1.0/tests/e2e/__init__.py +6 -0
  45. nlp2cmd-0.1.0/tests/e2e/conftest.py +402 -0
  46. nlp2cmd-0.1.0/tests/e2e/test_complete_flow.py +407 -0
  47. nlp2cmd-0.1.0/tests/e2e/test_domain_scenarios.py +541 -0
  48. nlp2cmd-0.1.0/tests/e2e/test_registry_validation.py +378 -0
  49. nlp2cmd-0.1.0/tests/integration/__init__.py +5 -0
  50. nlp2cmd-0.1.0/tests/integration/test_workflows.py +474 -0
  51. nlp2cmd-0.1.0/tests/iterative/__init__.py +9 -0
  52. nlp2cmd-0.1.0/tests/iterative/test_iter_0_baseline.py +484 -0
  53. nlp2cmd-0.1.0/tests/iterative/test_iter_10_thermodynamic.py +387 -0
  54. nlp2cmd-0.1.0/tests/iterative/test_iter_1_keywords.py +405 -0
  55. nlp2cmd-0.1.0/tests/iterative/test_iter_2_regex.py +375 -0
  56. nlp2cmd-0.1.0/tests/iterative/test_iter_3_templates.py +619 -0
  57. nlp2cmd-0.1.0/tests/iterative/test_iter_4_5_llm.py +323 -0
  58. nlp2cmd-0.1.0/tests/iterative/test_iter_6_7_structured.py +373 -0
  59. nlp2cmd-0.1.0/tests/iterative/test_iter_9_hybrid.py +363 -0
  60. nlp2cmd-0.1.0/tests/unit/test_adapters.py +344 -0
  61. nlp2cmd-0.1.0/tests/unit/test_adapters_comprehensive.py +255 -0
  62. nlp2cmd-0.1.0/tests/unit/test_core.py +237 -0
  63. nlp2cmd-0.1.0/tests/unit/test_core_comprehensive.py +526 -0
  64. nlp2cmd-0.1.0/tests/unit/test_environment.py +270 -0
  65. nlp2cmd-0.1.0/tests/unit/test_executor.py +593 -0
  66. nlp2cmd-0.1.0/tests/unit/test_feedback_comprehensive.py +479 -0
  67. nlp2cmd-0.1.0/tests/unit/test_planner_aggregator.py +522 -0
  68. nlp2cmd-0.1.0/tests/unit/test_registry.py +419 -0
  69. nlp2cmd-0.1.0/tests/unit/test_router.py +292 -0
  70. nlp2cmd-0.1.0/tests/unit/test_schemas_comprehensive.py +553 -0
  71. nlp2cmd-0.1.0/tests/unit/test_schemas_feedback.py +323 -0
  72. nlp2cmd-0.1.0/tests/unit/test_sequential_dsl_generation.py +21 -0
  73. nlp2cmd-0.1.0/tests/unit/test_thermodynamic.py +425 -0
  74. nlp2cmd-0.1.0/tests/unit/test_validators_comprehensive.py +331 -0
@@ -0,0 +1,163 @@
1
+ .idea
2
+ # Byte-compiled / optimized / DLL files
3
+ __pycache__/
4
+ *.py[cod]
5
+ *$py.class
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *.cover
48
+ *.py,cover
49
+ .hypothesis/
50
+ .pytest_cache/
51
+ cover/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+ db.sqlite3-journal
62
+
63
+ # Flask stuff:
64
+ instance/
65
+ .webassets-cache
66
+
67
+ # Scrapy stuff:
68
+ .scrapy
69
+
70
+ # Sphinx documentation
71
+ docs/_build/
72
+
73
+ # PyBuilder
74
+ .pybuilder/
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ Pipfile.lock
89
+
90
+ # poetry
91
+ poetry.lock
92
+
93
+ # pdm
94
+ .pdm.toml
95
+ .pdm-python
96
+ .pdm-build/
97
+
98
+ # PEP 582
99
+ __pypackages__/
100
+
101
+ # Celery stuff
102
+ celerybeat-schedule
103
+ celerybeat.pid
104
+
105
+ # SageMath parsed files
106
+ *.sage.py
107
+
108
+ # Environments
109
+ .env
110
+ .venv
111
+ env/
112
+ venv/
113
+ ENV/
114
+ env.bak/
115
+ venv.bak/
116
+
117
+ # Spyder project settings
118
+ .spyderproject
119
+ .spyproject
120
+
121
+ # Rope project settings
122
+ .ropeproject
123
+
124
+ # mkdocs documentation
125
+ /site
126
+
127
+ # mypy
128
+ .mypy_cache/
129
+ .dmypy.json
130
+ dmypy.json
131
+
132
+ # Pyre type checker
133
+ .pyre/
134
+
135
+ # pytype static type analyzer
136
+ .pytype/
137
+
138
+ # Cython debug symbols
139
+ cython_debug/
140
+
141
+ # IDE
142
+ .idea/
143
+ .vscode/
144
+ *.swp
145
+ *.swo
146
+ *~
147
+
148
+ # OS
149
+ .DS_Store
150
+ Thumbs.db
151
+
152
+ # Project specific
153
+ *.bak
154
+ *.backup
155
+ reports/
156
+ *.json.bak
157
+ env-report.json
158
+
159
+ # Secrets
160
+ .env.local
161
+ .env.*.local
162
+ secrets/
163
+ credentials/
nlp2cmd-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 NLP2CMD Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
nlp2cmd-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,505 @@
1
+ Metadata-Version: 2.4
2
+ Name: nlp2cmd
3
+ Version: 0.1.0
4
+ Summary: Natural Language to Domain-Specific Commands with Thermodynamic Optimization - Transform natural language into SQL, Shell, Docker, Kubernetes and solve optimization problems using Langevin dynamics
5
+ Project-URL: Homepage, https://github.com/example/nlp2cmd
6
+ Project-URL: Documentation, https://nlp2cmd.readthedocs.io
7
+ Project-URL: Repository, https://github.com/example/nlp2cmd
8
+ Project-URL: Issues, https://github.com/example/nlp2cmd/issues
9
+ Project-URL: Changelog, https://github.com/example/nlp2cmd/blob/main/CHANGELOG.md
10
+ Author-email: NLP2CMD Team <team@nlp2cmd.dev>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: ai,command-generation,constraint-satisfaction,docker,dsl,energy-models,kubernetes,langevin,llm,natural-language-processing,nlp,optimization,shell,sql,thermodynamic
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: System Administrators
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Software Development :: Code Generators
25
+ Classifier: Topic :: System :: Systems Administration
26
+ Classifier: Topic :: Text Processing :: Linguistic
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: click>=8.0
30
+ Requires-Dist: httpx>=0.25.0
31
+ Requires-Dist: jinja2>=3.0
32
+ Requires-Dist: jsonschema>=4.0
33
+ Requires-Dist: numpy>=1.24.0
34
+ Requires-Dist: pydantic>=2.0
35
+ Requires-Dist: python-dotenv>=1.0
36
+ Requires-Dist: pyyaml>=6.0
37
+ Requires-Dist: rich>=13.0
38
+ Requires-Dist: watchdog>=3.0
39
+ Provides-Extra: all
40
+ Requires-Dist: anthropic>=0.18; extra == 'all'
41
+ Requires-Dist: black>=23.0; extra == 'all'
42
+ Requires-Dist: matplotlib>=3.7.0; extra == 'all'
43
+ Requires-Dist: mkdocs-material>=9.0; extra == 'all'
44
+ Requires-Dist: mkdocs>=1.5; extra == 'all'
45
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'all'
46
+ Requires-Dist: mypy>=1.0; extra == 'all'
47
+ Requires-Dist: openai>=1.0; extra == 'all'
48
+ Requires-Dist: pre-commit>=3.0; extra == 'all'
49
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'all'
50
+ Requires-Dist: pytest-cov>=4.0; extra == 'all'
51
+ Requires-Dist: pytest>=7.0; extra == 'all'
52
+ Requires-Dist: ruff>=0.1; extra == 'all'
53
+ Requires-Dist: scipy>=1.10.0; extra == 'all'
54
+ Requires-Dist: spacy>=3.7; extra == 'all'
55
+ Requires-Dist: sqlalchemy>=2.0; extra == 'all'
56
+ Requires-Dist: sqlparse>=0.4; extra == 'all'
57
+ Provides-Extra: dev
58
+ Requires-Dist: black>=23.0; extra == 'dev'
59
+ Requires-Dist: mkdocs-material>=9.0; extra == 'dev'
60
+ Requires-Dist: mkdocs>=1.5; extra == 'dev'
61
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'dev'
62
+ Requires-Dist: mypy>=1.0; extra == 'dev'
63
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
64
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
65
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
66
+ Requires-Dist: pytest>=7.0; extra == 'dev'
67
+ Requires-Dist: ruff>=0.1; extra == 'dev'
68
+ Provides-Extra: llm
69
+ Requires-Dist: anthropic>=0.18; extra == 'llm'
70
+ Requires-Dist: openai>=1.0; extra == 'llm'
71
+ Provides-Extra: nlp
72
+ Requires-Dist: spacy>=3.7; extra == 'nlp'
73
+ Provides-Extra: sql
74
+ Requires-Dist: sqlalchemy>=2.0; extra == 'sql'
75
+ Requires-Dist: sqlparse>=0.4; extra == 'sql'
76
+ Provides-Extra: thermodynamic
77
+ Requires-Dist: matplotlib>=3.7.0; extra == 'thermodynamic'
78
+ Requires-Dist: scipy>=1.10.0; extra == 'thermodynamic'
79
+ Description-Content-Type: text/markdown
80
+
81
+ # NLP2CMD
82
+
83
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
84
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
85
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
86
+
87
+ **Natural Language to Domain-Specific Commands** - Production-ready framework for transforming natural language into DSL commands with full safety, validation, and observability.
88
+
89
+ ## ๐Ÿ—๏ธ Architecture v0.2.0: LLM as Planner + Typed Actions
90
+
91
+ ```
92
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
93
+ โ”‚ User Query โ”‚
94
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
95
+ โ”‚
96
+ โ–ผ
97
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
98
+ โ”‚ NLP Layer โ”‚ โ†’ Intent + Entities
99
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
100
+ โ”‚
101
+ โ–ผ
102
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
103
+ โ”‚ Decision Router โ”‚ โ†’ Direct OR LLM Planner?
104
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
105
+ โ”‚
106
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
107
+ โ”‚ โ”‚
108
+ โ–ผ โ–ผ
109
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
110
+ โ”‚ Direct โ”‚ โ”‚ LLM Planner โ”‚ โ†’ JSON Plan
111
+ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
112
+ โ”‚ โ”‚
113
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
114
+ โ”‚
115
+ โ–ผ
116
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
117
+ โ”‚ Plan Validator โ”‚ โ†’ Check against Action Registry
118
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
119
+ โ”‚
120
+ โ–ผ
121
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
122
+ โ”‚ Plan Executor โ”‚ โ†’ Execute Typed Actions
123
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
124
+ โ”‚
125
+ โ–ผ
126
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
127
+ โ”‚Result Aggregatorโ”‚ โ†’ Format Output
128
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
129
+ โ”‚
130
+ โ–ผ
131
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
132
+ โ”‚ User Output โ”‚
133
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
134
+ ```
135
+
136
+ **Key Principle: LLM plans. Code executes. System controls.**
137
+
138
+ ## โœจ Features
139
+
140
+ ### Core Capabilities
141
+ - ๐Ÿ—ฃ๏ธ **5 DSL Adapters**: SQL, Shell, Docker, Kubernetes, DQL (Doctrine)
142
+ - ๐Ÿ“ **11 File Format Schemas**: Dockerfile, docker-compose, K8s manifests, GitHub workflows, .env, and more
143
+ - ๐Ÿ›ก๏ธ **Safety Policies**: Allowlist-based action control, no eval/shell execution
144
+ - ๐Ÿ”„ **Multi-step Plans**: Support for `foreach` loops and variable references between steps
145
+
146
+ ### New Architecture Components (v0.2.0)
147
+ - ๐Ÿ”€ **Decision Router**: Intelligently routes queries to direct execution or LLM planner
148
+ - ๐Ÿ“‹ **Action Registry**: Central registry of 19+ typed actions with full validation
149
+ - โšก **Plan Executor**: Executes multi-step plans with tracing, retry, and error handling
150
+ - ๐Ÿค– **LLM Planner**: Generates JSON plans constrained to allowed actions
151
+ - ๐Ÿ“Š **Result Aggregator**: Multiple output formats (text, table, JSON, markdown)
152
+
153
+ ### Security Features
154
+ - โœ… No direct LLM access to system
155
+ - โœ… Typed actions (no eval/shell)
156
+ - โœ… Allowlist of permitted actions
157
+ - โœ… Full plan validation before execution
158
+ - โœ… Traceable execution (trace_id per request)
159
+
160
+ ## ๐Ÿ“š Documentation
161
+
162
+ | Document | Description |
163
+ |----------|-------------|
164
+ | **[Installation Guide](INSTALLATION.md)** | Setup instructions and installation options |
165
+ | **[User Guide](docs/guides/user-guide.md)** | Complete usage tutorial and examples |
166
+ | **[API Reference](docs/api/README.md)** | Detailed API documentation |
167
+ | **[Thermodynamic Integration](THERMODYNAMIC_INTEGRATION.md)** | Advanced optimization with Langevin dynamics |
168
+ | **[Thermodynamic Architecture](THERMODYNAMIC_ARCHITECTURE.md)** | Deep technical architecture overview |
169
+ | **[Contributing Guide](CONTRIBUTING.md)** | Development guidelines and contribution process |
170
+ | **[Generation Module](README_GENERATION.md)** | DSL generation implementation details |
171
+
172
+ ## ๐Ÿš€ Quick Start
173
+
174
+ ### Installation
175
+
176
+ ```bash
177
+ pip install nlp2cmd
178
+ ```
179
+
180
+ Or from source:
181
+
182
+ ```bash
183
+ git clone https://github.com/example/nlp2cmd.git
184
+ cd nlp2cmd
185
+ pip install -e ".[dev]"
186
+ ```
187
+
188
+ ### Basic Usage (New Architecture)
189
+
190
+ ```python
191
+ from nlp2cmd import (
192
+ DecisionRouter,
193
+ RoutingDecision,
194
+ PlanExecutor,
195
+ ExecutionPlan,
196
+ PlanStep,
197
+ ResultAggregator,
198
+ OutputFormat,
199
+ get_registry,
200
+ )
201
+
202
+ # Initialize components
203
+ router = DecisionRouter()
204
+ executor = PlanExecutor()
205
+ aggregator = ResultAggregator()
206
+
207
+ # Route a query
208
+ routing = router.route(
209
+ intent="select",
210
+ entities={"table": "users"},
211
+ text="show all users",
212
+ confidence=0.9,
213
+ )
214
+
215
+ if routing.decision == RoutingDecision.DIRECT:
216
+ # Simple query - direct execution
217
+ plan = ExecutionPlan(steps=[
218
+ PlanStep(action="sql_select", params={"table": "users"})
219
+ ])
220
+ else:
221
+ # Complex query - use LLM Planner
222
+ from nlp2cmd import LLMPlanner
223
+ planner = LLMPlanner(llm_client=your_llm_client)
224
+ result = planner.plan(intent="select", entities={}, text="...")
225
+ plan = result.plan
226
+
227
+ # Execute and format results
228
+ exec_result = executor.execute(plan)
229
+ output = aggregator.aggregate(exec_result, format=OutputFormat.TABLE)
230
+ print(output.data)
231
+ ```
232
+
233
+ ### Multi-Step Plans with Foreach
234
+
235
+ ```python
236
+ # Define a multi-step plan
237
+ plan = ExecutionPlan(steps=[
238
+ PlanStep(
239
+ action="shell_find",
240
+ params={"glob": "*.log"},
241
+ store_as="log_files",
242
+ ),
243
+ PlanStep(
244
+ action="shell_count_pattern",
245
+ foreach="log_files", # Iterate over results
246
+ params={"file": "$item", "pattern": "ERROR"},
247
+ store_as="error_counts",
248
+ ),
249
+ PlanStep(
250
+ action="summarize_results",
251
+ params={"data": "$error_counts"},
252
+ ),
253
+ ])
254
+
255
+ # Execute with tracing
256
+ result = executor.execute(plan)
257
+ print(f"Trace ID: {result.trace_id}")
258
+ print(f"Duration: {result.total_duration_ms}ms")
259
+ ```
260
+
261
+ ### Legacy Usage (SQL Adapter)
262
+
263
+ ```python
264
+ from nlp2cmd import NLP2CMD, SQLAdapter
265
+
266
+ # Initialize with SQL adapter
267
+ nlp = NLP2CMD(adapter=SQLAdapter(dialect="postgresql"))
268
+
269
+ # Transform natural language to SQL
270
+ result = nlp.transform("Pokaลผ wszystkich uลผytkownikรณw z Warszawy")
271
+ print(result.command) # SELECT * FROM users WHERE city = 'Warszawa';
272
+ ```
273
+
274
+ ## ๐Ÿ“‹ Action Registry
275
+
276
+ ```python
277
+ from nlp2cmd import get_registry
278
+
279
+ registry = get_registry()
280
+
281
+ # List all domains
282
+ print(registry.list_domains())
283
+ # ['sql', 'shell', 'docker', 'kubernetes', 'utility']
284
+
285
+ # List actions by domain
286
+ print(registry.list_actions(domain="sql"))
287
+ # ['sql_select', 'sql_insert', 'sql_update', 'sql_delete', 'sql_aggregate']
288
+
289
+ # Get destructive actions (require confirmation)
290
+ print(registry.get_destructive_actions())
291
+ # ['sql_insert', 'sql_update', 'sql_delete', 'docker_run', ...]
292
+
293
+ # Generate LLM prompt with available actions
294
+ prompt = registry.to_llm_prompt(domain="sql")
295
+ ```
296
+
297
+ ## ๐Ÿ”ง DSL Support
298
+
299
+ | DSL | Adapter | Status |
300
+ |-----|---------|--------|
301
+ | SQL (PostgreSQL, MySQL, SQLite) | `SQLAdapter` | โœ… Stable |
302
+ | Shell (Bash, Zsh) | `ShellAdapter` | โœ… Stable |
303
+ | DQL (Doctrine) | `DQLAdapter` | โœ… Stable |
304
+ | Docker / Docker Compose | `DockerAdapter` | โœ… Stable |
305
+ | Kubernetes | `KubernetesAdapter` | โœ… Stable |
306
+
307
+ ## ๐Ÿ“ Supported File Formats
308
+
309
+ - Dockerfile
310
+ - docker-compose.yml
311
+ - Kubernetes manifests (Deployment, Service, Ingress, ConfigMap)
312
+ - SQL migrations
313
+ - .env files
314
+ - nginx.conf
315
+ - GitHub Actions workflows
316
+ - Prisma Schema
317
+ - Terraform (.tf)
318
+ - .editorconfig
319
+ - package.json
320
+
321
+ ## ๐Ÿ“Š Output Formats
322
+
323
+ ```python
324
+ from nlp2cmd import ResultAggregator, OutputFormat
325
+
326
+ aggregator = ResultAggregator()
327
+
328
+ # Text format (default)
329
+ result = aggregator.aggregate(exec_result, format=OutputFormat.TEXT)
330
+
331
+ # ASCII Table
332
+ result = aggregator.aggregate(exec_result, format=OutputFormat.TABLE)
333
+
334
+ # JSON (for programmatic use)
335
+ result = aggregator.aggregate(exec_result, format=OutputFormat.JSON)
336
+
337
+ # Markdown (for documentation)
338
+ result = aggregator.aggregate(exec_result, format=OutputFormat.MARKDOWN)
339
+
340
+ # Summary (for dashboards)
341
+ result = aggregator.aggregate(exec_result, format=OutputFormat.SUMMARY)
342
+ ```
343
+
344
+ ## ๐Ÿ›ก๏ธ Safety
345
+
346
+ The framework enforces safety at multiple levels:
347
+
348
+ 1. **Action Allowlist**: Only registered actions can be executed
349
+ 2. **Parameter Validation**: Full type checking and constraints
350
+ 3. **Plan Validation**: All plans validated before execution
351
+ 4. **No Code Generation**: LLM only produces JSON plans, not executable code
352
+ 5. **Destructive Action Marking**: Actions that modify state are flagged
353
+
354
+ ## ๐Ÿงช Testing
355
+
356
+ ```bash
357
+ # Run all tests
358
+ pytest tests/ -v
359
+
360
+ # Run specific component tests
361
+ pytest tests/unit/test_router.py -v
362
+ pytest tests/unit/test_registry.py -v
363
+ pytest tests/unit/test_executor.py -v
364
+
365
+ # Thermodynamic optimization tests
366
+ PYTHONPATH=/home/tom/github/wronai/nlp2cmd/src python3 -m pytest \
367
+ tests/iterative/test_iter_10_thermodynamic.py -v
368
+
369
+ # With coverage
370
+ pytest --cov=nlp2cmd --cov-report=html
371
+ ```
372
+
373
+ ## ๐Ÿ”ฌ Thermodynamic Optimization (v0.3.0+)
374
+
375
+ Based on [Whitelam (2025) "Generative thermodynamic computing"](https://arxiv.org/abs/2506.15121), the framework now includes thermodynamic optimization for complex constraint satisfaction problems.
376
+
377
+ ### Key Features
378
+
379
+ - **Langevin Dynamics Sampling**: Natural evolution from noise to structured solutions
380
+ - **Energy-Based Models**: Domain-specific constraint functions
381
+ - **Hybrid Routing**: Automatic selection between DSL generation and thermodynamic optimization
382
+ - **Energy Efficiency**: 50-70% reduction vs pure LLM inference
383
+
384
+ ### Quick Example
385
+
386
+ ```python
387
+ from nlp2cmd.generation import create_hybrid_generator
388
+
389
+ # Create hybrid generator (DSL + Thermodynamic)
390
+ hybrid = create_hybrid_generator()
391
+
392
+ # Simple query โ†’ DSL generation (2ms, $0)
393
+ result = await hybrid.generate("SELECT * FROM users")
394
+ print(result['source']) # 'dsl'
395
+
396
+ # Complex optimization โ†’ Thermodynamic sampling (~200ms, ~$0.01)
397
+ result = await hybrid.generate("Zaplanuj 5 zadaล„ w 10 slotach z ograniczeniami")
398
+ print(result['source']) # 'thermodynamic'
399
+ print(result['result'].decoded_output)
400
+ # Schedule:
401
+ # Slot 0: task_0
402
+ # Slot 2: task_1
403
+ # Slot 4: task_2
404
+
405
+ # Energy savings estimate
406
+ print(result['result'].energy_estimate)
407
+ # {'savings_digital_percent': 65.2, 'savings_analog_percent': 98.7}
408
+ ```
409
+
410
+ ### Supported Problem Types
411
+
412
+ - **Scheduling**: Task scheduling with deadlines and constraints
413
+ - **Resource Allocation**: Optimal distribution under capacity limits
414
+ - **Planning**: Multi-step planning with constraint satisfaction
415
+ - **Optimization**: General constrained optimization problems
416
+
417
+ See [Thermodynamic Integration](THERMODYNAMIC_INTEGRATION.md) for detailed documentation.
418
+
419
+ ## ๐Ÿ’ก Examples
420
+
421
+ ### Quick Examples
422
+ - **[Basic SQL](examples/sql/basic_sql.py)** - Simple SQL queries
423
+ - **[Shell Commands](examples/shell/basic_shell.py)** - Common shell operations
424
+ - **[Docker Management](examples/docker/basic_docker.py)** - Container operations
425
+ - **[Kubernetes](examples/kubernetes/basic_kubernetes.py)** - K8s cluster management
426
+
427
+ ### Advanced Examples
428
+ - **[End-to-End Demo](examples/architecture/end_to_end_demo.py)** - Complete workflow
429
+ - **[Log Analysis Pipeline](examples/pipelines/log_analysis.py)** - Data processing
430
+ - **[Infrastructure Health](examples/pipelines/infrastructure_health.py)** - System monitoring
431
+ - **[Configuration Validation](examples/validation/config_validation.py)** - File validation
432
+
433
+ ### Use Case Examples
434
+ - **[DevOps Automation](examples/use_cases/devops_automation.py)** - IT operations
435
+ - **[Data Science & ML](examples/use_cases/data_science_ml.py)** - Data workflows
436
+ - **[Healthcare](examples/use_cases/healthcare.py)** - Medical applications
437
+ - **[Finance & Trading](examples/use_cases/finance_trading.py)** - Financial operations
438
+ - **[Smart Cities](examples/use_cases/smart_cities.py)** - Urban management
439
+
440
+ See [Examples README](examples/use_cases/README.md) for all available examples.
441
+
442
+ ## ๐Ÿ“ Project Structure
443
+
444
+ ```
445
+ nlp2cmd/
446
+ โ”œโ”€โ”€ src/nlp2cmd/
447
+ โ”‚ โ”œโ”€โ”€ __init__.py # Main exports
448
+ โ”‚ โ”œโ”€โ”€ core.py # Core NLP2CMD class
449
+ โ”‚ โ”œโ”€โ”€ router/ # Decision Router
450
+ โ”‚ โ”œโ”€โ”€ registry/ # Action Registry
451
+ โ”‚ โ”œโ”€โ”€ executor/ # Plan Executor
452
+ โ”‚ โ”œโ”€โ”€ planner/ # LLM Planner
453
+ โ”‚ โ”œโ”€โ”€ aggregator/ # Result Aggregator
454
+ โ”‚ โ”œโ”€โ”€ adapters/ # DSL Adapters (SQL, Shell, Docker, K8s, DQL)
455
+ โ”‚ โ”œโ”€โ”€ schemas/ # File Format Schemas
456
+ โ”‚ โ”œโ”€โ”€ feedback/ # Feedback Loop
457
+ โ”‚ โ”œโ”€โ”€ environment/ # Environment Analyzer
458
+ โ”‚ โ””โ”€โ”€ validators/ # Validators
459
+ โ”œโ”€โ”€ tests/
460
+ โ”‚ โ”œโ”€โ”€ unit/ # Unit tests (~150 tests)
461
+ โ”‚ โ””โ”€โ”€ integration/ # Integration tests
462
+ โ”œโ”€โ”€ examples/
463
+ โ”‚ โ”œโ”€โ”€ architecture/ # End-to-end demos
464
+ โ”‚ โ”œโ”€โ”€ sql/ # SQL examples
465
+ โ”‚ โ”œโ”€โ”€ shell/ # Shell examples
466
+ โ”‚ โ””โ”€โ”€ docker/ # Docker examples
467
+ โ””โ”€โ”€ docs/ # Documentation
468
+ ```
469
+
470
+ ## ๐Ÿ”– Version History
471
+
472
+ ### v0.3.0+ (Thermodynamic Integration)
473
+ - **NEW**: Thermodynamic optimization using Whitelam's generative framework
474
+ - Langevin dynamics for constraint satisfaction problems
475
+ - 50-70% energy reduction vs pure LLM inference
476
+ - Hybrid router: DSL generation + thermodynamic optimization
477
+ - Domain-specific energy models (scheduling, allocation, planning)
478
+ - Parallel sampling with energy-based voting
479
+
480
+ ### v0.2.0 (Current)
481
+ - New architecture: LLM as Planner + Typed Actions
482
+ - Decision Router for intelligent query routing
483
+ - Action Registry with 19+ typed actions
484
+ - Plan Executor with foreach, conditions, and retry
485
+ - Result Aggregator with multiple output formats
486
+ - Full observability (trace_id, duration tracking)
487
+ - 150+ tests
488
+
489
+ ### v0.1.0
490
+ - Initial release
491
+ - 5 DSL adapters
492
+ - 11 file format schemas
493
+ - Safety policies
494
+ - Feedback loop
495
+
496
+ ## ๐Ÿ“„ License
497
+
498
+ MIT License - see [LICENSE](LICENSE) for details.
499
+
500
+ ## ๐Ÿ™ Acknowledgements
501
+
502
+ - [Whitelam, S. (2025)](https://arxiv.org/abs/2506.15121) "Generative thermodynamic computing" - Theoretical foundation for thermodynamic optimization
503
+ - [spaCy](https://spacy.io/) - NLP processing
504
+ - [Anthropic Claude](https://anthropic.com/) - LLM integration
505
+ - [Rich](https://rich.readthedocs.io/) - Terminal formatting