nlp2uri 0.1.1__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 (38) hide show
  1. nlp2uri-0.1.1/LICENSE +201 -0
  2. nlp2uri-0.1.1/PKG-INFO +188 -0
  3. nlp2uri-0.1.1/README.md +164 -0
  4. nlp2uri-0.1.1/pyproject.toml +68 -0
  5. nlp2uri-0.1.1/setup.cfg +4 -0
  6. nlp2uri-0.1.1/src/nlp2uri/__init__.py +22 -0
  7. nlp2uri-0.1.1/src/nlp2uri/cli.py +116 -0
  8. nlp2uri-0.1.1/src/nlp2uri/compile.py +258 -0
  9. nlp2uri-0.1.1/src/nlp2uri/mcp.py +92 -0
  10. nlp2uri-0.1.1/src/nlp2uri/models.py +174 -0
  11. nlp2uri-0.1.1/src/nlp2uri/parse_nl.py +218 -0
  12. nlp2uri-0.1.1/src/nlp2uri/platform_detect.py +18 -0
  13. nlp2uri-0.1.1/src/nlp2uri/platforms/__init__.py +6 -0
  14. nlp2uri-0.1.1/src/nlp2uri/platforms/base.py +130 -0
  15. nlp2uri-0.1.1/src/nlp2uri/platforms/linux.py +145 -0
  16. nlp2uri-0.1.1/src/nlp2uri/platforms/macos.py +94 -0
  17. nlp2uri-0.1.1/src/nlp2uri/platforms/registry.py +24 -0
  18. nlp2uri-0.1.1/src/nlp2uri/platforms/windows.py +94 -0
  19. nlp2uri-0.1.1/src/nlp2uri/resolve.py +39 -0
  20. nlp2uri-0.1.1/src/nlp2uri/runtime.py +92 -0
  21. nlp2uri-0.1.1/src/nlp2uri/schemes/__init__.py +5 -0
  22. nlp2uri-0.1.1/src/nlp2uri/schemes/build.py +59 -0
  23. nlp2uri-0.1.1/src/nlp2uri/schemes/desktop.py +94 -0
  24. nlp2uri-0.1.1/src/nlp2uri/schemes/file.py +25 -0
  25. nlp2uri-0.1.1/src/nlp2uri/schemes/http.py +22 -0
  26. nlp2uri-0.1.1/src/nlp2uri/schemes/ide.py +35 -0
  27. nlp2uri-0.1.1/src/nlp2uri/schemes/util.py +47 -0
  28. nlp2uri-0.1.1/src/nlp2uri.egg-info/PKG-INFO +188 -0
  29. nlp2uri-0.1.1/src/nlp2uri.egg-info/SOURCES.txt +36 -0
  30. nlp2uri-0.1.1/src/nlp2uri.egg-info/dependency_links.txt +1 -0
  31. nlp2uri-0.1.1/src/nlp2uri.egg-info/entry_points.txt +2 -0
  32. nlp2uri-0.1.1/src/nlp2uri.egg-info/requires.txt +20 -0
  33. nlp2uri-0.1.1/src/nlp2uri.egg-info/top_level.txt +1 -0
  34. nlp2uri-0.1.1/tests/test_cli.py +30 -0
  35. nlp2uri-0.1.1/tests/test_compile.py +33 -0
  36. nlp2uri-0.1.1/tests/test_mcp.py +24 -0
  37. nlp2uri-0.1.1/tests/test_platforms.py +47 -0
  38. nlp2uri-0.1.1/tests/test_resolve.py +76 -0
nlp2uri-0.1.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
nlp2uri-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: nlp2uri
3
+ Version: 0.1.1
4
+ Summary: Natural language to URI resolution and cross-platform local URI execution
5
+ Author: Semcod
6
+ Author-email: Tom Sapletta <tom@sapletta.com>
7
+ License-Expression: Apache-2.0
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=8.0; extra == "dev"
13
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
14
+ Requires-Dist: goal>=2.1.0; extra == "dev"
15
+ Requires-Dist: costs>=0.1.20; extra == "dev"
16
+ Requires-Dist: pfix>=0.1.60; extra == "dev"
17
+ Provides-Extra: linux
18
+ Requires-Dist: dbus-python>=1.3.2; sys_platform == "linux" and extra == "linux"
19
+ Provides-Extra: windows
20
+ Requires-Dist: pywin32>=306; sys_platform == "win32" and extra == "windows"
21
+ Provides-Extra: full
22
+ Requires-Dist: psutil>=6.0; extra == "full"
23
+ Dynamic: license-file
24
+
25
+ # nlp2uri
26
+
27
+
28
+ ## AI Cost Tracking
29
+
30
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
31
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.15-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-1.0h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
32
+
33
+ - 🤖 **LLM usage:** $0.1500 (1 commits)
34
+ - 👤 **Human dev:** ~$100 (1.0h @ $100/h, 30min dedup)
35
+
36
+ Generated on 2026-06-06 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
37
+
38
+ ---
39
+
40
+
41
+
42
+ Python library and CLI — **kompilator NL → URI → akcje OS** dla operacji desktopowych.
43
+
44
+ Wejście (naturalny język):
45
+
46
+ - „otwórz VS Code w folderze ~/projekty/nlp2uri”
47
+ - „zrób screenshot aktywnego okna przeglądarki”
48
+ - „otwórz plik invoice-2025.pdf”
49
+
50
+ Wyjście:
51
+
52
+ 1. **Abstrakcyjny URI** (RFC 3986, niezależny od OS)
53
+ 2. **Plan akcji** `OSAction[]` — konkretne komendy per platforma
54
+ 3. (Opcjonalnie) wykonanie lub payload MCP (`text/uri-list`)
55
+
56
+ ## Architektura
57
+
58
+ ```mermaid
59
+ flowchart LR
60
+ NL[Natural language] --> PARSE[parse_nl]
61
+ PARSE --> INTENT[UriIntent + slots]
62
+ INTENT --> BUILD[schemes/build]
63
+ BUILD --> SPEC[UriSpec abstract URI]
64
+ SPEC --> COMPILE[compile_uri_to_actions]
65
+ COMPILE --> ACTIONS[OSAction plan]
66
+ ACTIONS --> EXEC[execute_uri / MCP]
67
+ ```
68
+
69
+ ### Warstwy
70
+
71
+ | Warstwa | Moduł | Opis |
72
+ |---------|-------|------|
73
+ | NLP → intencja | `parse_nl` | Heurystyki EN + PL → `UriIntent` |
74
+ | Intencja → URI | `schemes/*` | Abstrakcyjne schemy OS-neutral |
75
+ | URI → OS | `compile` | `compile_uri_to_actions()` |
76
+ | Wykonanie | `runtime` | `subprocess` / dry-run |
77
+ | MCP | `mcp` | `text/uri-list`, tool payloads |
78
+
79
+ ## Abstrakcyjne schemy URI
80
+
81
+ | Scheme | Przykład | Znaczenie |
82
+ |--------|----------|-----------|
83
+ | `app://` | `app://vscode/open?path=/home/tom/...` | Otwórz aplikację / IDE |
84
+ | `app://file/open` | `app://file/open?path=/tmp/x.pdf` | Otwórz plik |
85
+ | `desktop-screenshot://` | `desktop-screenshot://window?title=Chrome&mode=active` | Screenshot okna/ekranu |
86
+ | `desktop-window://` | `desktop-window://focus?name=slack` | Fokus okna |
87
+ | natywne | `vscode://`, `cursor://`, `file://`, `ms-settings:` | Passthrough do handlera OS |
88
+
89
+ Metadata `native_uri` zawiera deep-link IDE (`vscode://file/...`) gdy istnieje.
90
+
91
+ ## Quick start
92
+
93
+ ```bash
94
+ pip install -e ".[dev]"
95
+
96
+ # Pełny plan: URI + OSActions
97
+ nlp2uri plan "otwórz vscode w folderze ~/github/semcod/nlp2uri" --platform linux --json
98
+
99
+ # Tylko URI
100
+ nlp2uri resolve "zrób screenshot aktywnego okna przeglądarki" --platform linux --json
101
+
102
+ # URI → komendy
103
+ nlp2uri compile "desktop-screenshot://window?title=Chrome&mode=active" --platform linux --json
104
+
105
+ # Dry-run (bezpieczne w CI/Docker)
106
+ nlp2uri execute "open firefox" --platform linux --dry-run
107
+ ```
108
+
109
+ ## Python API
110
+
111
+ ```python
112
+ from nlp2uri import nlp2uri, compile_uri_to_actions, execute_uri
113
+ from nlp2uri.models import HostPlatform
114
+
115
+ plan = nlp2uri(
116
+ "otwórz vscode w folderze /tmp/foo",
117
+ os=HostPlatform.LINUX,
118
+ )
119
+ print(plan.uri) # app://vscode/open?path=/tmp/foo
120
+ print(plan.intent) # open_app
121
+ print(plan.slots) # {"app": "vscode", "resource": "/tmp/foo", ...}
122
+ print(plan.actions[0].argv()) # ['xdg-open', 'vscode://file/tmp/foo']
123
+
124
+ result = execute_uri(plan.uri, platform=HostPlatform.LINUX, dry_run=True)
125
+ ```
126
+
127
+ ## MCP server
128
+
129
+ ```python
130
+ from nlp2uri.mcp import tool_resolve_desktop_action, tool_execute_desktop_uri
131
+
132
+ # Tool 1: NL → URI + plan (zwraca text/uri-list)
133
+ tool_resolve_desktop_action("screenshot window titled Firefox", platform=HostPlatform.LINUX)
134
+
135
+ # Tool 2: wykonaj URI (lub dry-run)
136
+ tool_execute_desktop_uri("desktop-screenshot://screen", platform=HostPlatform.LINUX, dry_run=True)
137
+ ```
138
+
139
+ Host MCP może mapować `desktop-screenshot://...` na backend typu `mcp-desktop-pro` zamiast bezpośredniego `subprocess`.
140
+
141
+ ## Standardy
142
+
143
+ | Standard | Rola |
144
+ |----------|------|
145
+ | [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) | Składnia URI (`scheme`, `path`, `query`) |
146
+ | [RFC 8089](https://www.rfc-editor.org/rfc/rfc8089) | `file://` |
147
+ | [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110) | `http(s)://` |
148
+ | [Freedesktop Desktop Entry](https://specifications.freedesktop.org/desktop-entry-spec/latest/) | `.desktop`, `x-scheme-handler/<scheme>` |
149
+ | [XDG Desktop Portal](https://flatpak.github.io/xdg-desktop-portal/) | Screenshot Wayland |
150
+ | Windows URI activation | `ms-settings:`, rejestracja schemów |
151
+ | macOS URL Schemes | `CFBundleURLSchemes` w `Info.plist` |
152
+ | MCP `text/uri-list` | Lista URI dla hosta / MCP Apps |
153
+
154
+ ## Przydatne biblioteki
155
+
156
+ | Biblioteka | Kiedy |
157
+ |------------|-------|
158
+ | `urllib.parse`, `webbrowser`, `subprocess` | Już używane (stdlib) |
159
+ | `psutil` | PID → okno |
160
+ | `pyxdg` | Parsowanie `.desktop` |
161
+ | `dbus-python` + PyGObject | XDG Portal screenshot |
162
+ | `pywin32` | Win32 `SetForegroundWindow` |
163
+ | `pyobjc` / Quartz | macOS window ID |
164
+ | `spaCy` / `transformers` | Zamiast heurystyk regex |
165
+ | `nlp2dsl` / `nlp2cmd-intent` | IntentIR z LLM (jak `nlpshim`) |
166
+
167
+ ## Testy i Docker
168
+
169
+ ```bash
170
+ python -m pytest
171
+ docker compose build && docker compose run --rm nlp2uri-test
172
+ bash examples/run_all.sh
173
+ ```
174
+
175
+ W Dockerze:
176
+
177
+ - unit: NLP → URI → `OSAction`
178
+ - integracja: rejestracja `testapp://` przez `.desktop` + `xdg-open` (`NLP2URI_INTEGRATION=1`)
179
+
180
+ ## Relacja z ekosystemem Semcod
181
+
182
+ - **`nlpshim`** — NLP → DSL / workflow
183
+ - **`nlp2uri`** — NLP → URI → akcje desktopowe (MCP, screenshot, focus, open app)
184
+ - **`koru`** — `portal_capture.py` jako wzorzec dla Wayland screenshot
185
+
186
+ ## License
187
+
188
+ Licensed under Apache-2.0.
@@ -0,0 +1,164 @@
1
+ # nlp2uri
2
+
3
+
4
+ ## AI Cost Tracking
5
+
6
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
7
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.15-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-1.0h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
8
+
9
+ - 🤖 **LLM usage:** $0.1500 (1 commits)
10
+ - 👤 **Human dev:** ~$100 (1.0h @ $100/h, 30min dedup)
11
+
12
+ Generated on 2026-06-06 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
13
+
14
+ ---
15
+
16
+
17
+
18
+ Python library and CLI — **kompilator NL → URI → akcje OS** dla operacji desktopowych.
19
+
20
+ Wejście (naturalny język):
21
+
22
+ - „otwórz VS Code w folderze ~/projekty/nlp2uri”
23
+ - „zrób screenshot aktywnego okna przeglądarki”
24
+ - „otwórz plik invoice-2025.pdf”
25
+
26
+ Wyjście:
27
+
28
+ 1. **Abstrakcyjny URI** (RFC 3986, niezależny od OS)
29
+ 2. **Plan akcji** `OSAction[]` — konkretne komendy per platforma
30
+ 3. (Opcjonalnie) wykonanie lub payload MCP (`text/uri-list`)
31
+
32
+ ## Architektura
33
+
34
+ ```mermaid
35
+ flowchart LR
36
+ NL[Natural language] --> PARSE[parse_nl]
37
+ PARSE --> INTENT[UriIntent + slots]
38
+ INTENT --> BUILD[schemes/build]
39
+ BUILD --> SPEC[UriSpec abstract URI]
40
+ SPEC --> COMPILE[compile_uri_to_actions]
41
+ COMPILE --> ACTIONS[OSAction plan]
42
+ ACTIONS --> EXEC[execute_uri / MCP]
43
+ ```
44
+
45
+ ### Warstwy
46
+
47
+ | Warstwa | Moduł | Opis |
48
+ |---------|-------|------|
49
+ | NLP → intencja | `parse_nl` | Heurystyki EN + PL → `UriIntent` |
50
+ | Intencja → URI | `schemes/*` | Abstrakcyjne schemy OS-neutral |
51
+ | URI → OS | `compile` | `compile_uri_to_actions()` |
52
+ | Wykonanie | `runtime` | `subprocess` / dry-run |
53
+ | MCP | `mcp` | `text/uri-list`, tool payloads |
54
+
55
+ ## Abstrakcyjne schemy URI
56
+
57
+ | Scheme | Przykład | Znaczenie |
58
+ |--------|----------|-----------|
59
+ | `app://` | `app://vscode/open?path=/home/tom/...` | Otwórz aplikację / IDE |
60
+ | `app://file/open` | `app://file/open?path=/tmp/x.pdf` | Otwórz plik |
61
+ | `desktop-screenshot://` | `desktop-screenshot://window?title=Chrome&mode=active` | Screenshot okna/ekranu |
62
+ | `desktop-window://` | `desktop-window://focus?name=slack` | Fokus okna |
63
+ | natywne | `vscode://`, `cursor://`, `file://`, `ms-settings:` | Passthrough do handlera OS |
64
+
65
+ Metadata `native_uri` zawiera deep-link IDE (`vscode://file/...`) gdy istnieje.
66
+
67
+ ## Quick start
68
+
69
+ ```bash
70
+ pip install -e ".[dev]"
71
+
72
+ # Pełny plan: URI + OSActions
73
+ nlp2uri plan "otwórz vscode w folderze ~/github/semcod/nlp2uri" --platform linux --json
74
+
75
+ # Tylko URI
76
+ nlp2uri resolve "zrób screenshot aktywnego okna przeglądarki" --platform linux --json
77
+
78
+ # URI → komendy
79
+ nlp2uri compile "desktop-screenshot://window?title=Chrome&mode=active" --platform linux --json
80
+
81
+ # Dry-run (bezpieczne w CI/Docker)
82
+ nlp2uri execute "open firefox" --platform linux --dry-run
83
+ ```
84
+
85
+ ## Python API
86
+
87
+ ```python
88
+ from nlp2uri import nlp2uri, compile_uri_to_actions, execute_uri
89
+ from nlp2uri.models import HostPlatform
90
+
91
+ plan = nlp2uri(
92
+ "otwórz vscode w folderze /tmp/foo",
93
+ os=HostPlatform.LINUX,
94
+ )
95
+ print(plan.uri) # app://vscode/open?path=/tmp/foo
96
+ print(plan.intent) # open_app
97
+ print(plan.slots) # {"app": "vscode", "resource": "/tmp/foo", ...}
98
+ print(plan.actions[0].argv()) # ['xdg-open', 'vscode://file/tmp/foo']
99
+
100
+ result = execute_uri(plan.uri, platform=HostPlatform.LINUX, dry_run=True)
101
+ ```
102
+
103
+ ## MCP server
104
+
105
+ ```python
106
+ from nlp2uri.mcp import tool_resolve_desktop_action, tool_execute_desktop_uri
107
+
108
+ # Tool 1: NL → URI + plan (zwraca text/uri-list)
109
+ tool_resolve_desktop_action("screenshot window titled Firefox", platform=HostPlatform.LINUX)
110
+
111
+ # Tool 2: wykonaj URI (lub dry-run)
112
+ tool_execute_desktop_uri("desktop-screenshot://screen", platform=HostPlatform.LINUX, dry_run=True)
113
+ ```
114
+
115
+ Host MCP może mapować `desktop-screenshot://...` na backend typu `mcp-desktop-pro` zamiast bezpośredniego `subprocess`.
116
+
117
+ ## Standardy
118
+
119
+ | Standard | Rola |
120
+ |----------|------|
121
+ | [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) | Składnia URI (`scheme`, `path`, `query`) |
122
+ | [RFC 8089](https://www.rfc-editor.org/rfc/rfc8089) | `file://` |
123
+ | [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110) | `http(s)://` |
124
+ | [Freedesktop Desktop Entry](https://specifications.freedesktop.org/desktop-entry-spec/latest/) | `.desktop`, `x-scheme-handler/<scheme>` |
125
+ | [XDG Desktop Portal](https://flatpak.github.io/xdg-desktop-portal/) | Screenshot Wayland |
126
+ | Windows URI activation | `ms-settings:`, rejestracja schemów |
127
+ | macOS URL Schemes | `CFBundleURLSchemes` w `Info.plist` |
128
+ | MCP `text/uri-list` | Lista URI dla hosta / MCP Apps |
129
+
130
+ ## Przydatne biblioteki
131
+
132
+ | Biblioteka | Kiedy |
133
+ |------------|-------|
134
+ | `urllib.parse`, `webbrowser`, `subprocess` | Już używane (stdlib) |
135
+ | `psutil` | PID → okno |
136
+ | `pyxdg` | Parsowanie `.desktop` |
137
+ | `dbus-python` + PyGObject | XDG Portal screenshot |
138
+ | `pywin32` | Win32 `SetForegroundWindow` |
139
+ | `pyobjc` / Quartz | macOS window ID |
140
+ | `spaCy` / `transformers` | Zamiast heurystyk regex |
141
+ | `nlp2dsl` / `nlp2cmd-intent` | IntentIR z LLM (jak `nlpshim`) |
142
+
143
+ ## Testy i Docker
144
+
145
+ ```bash
146
+ python -m pytest
147
+ docker compose build && docker compose run --rm nlp2uri-test
148
+ bash examples/run_all.sh
149
+ ```
150
+
151
+ W Dockerze:
152
+
153
+ - unit: NLP → URI → `OSAction`
154
+ - integracja: rejestracja `testapp://` przez `.desktop` + `xdg-open` (`NLP2URI_INTEGRATION=1`)
155
+
156
+ ## Relacja z ekosystemem Semcod
157
+
158
+ - **`nlpshim`** — NLP → DSL / workflow
159
+ - **`nlp2uri`** — NLP → URI → akcje desktopowe (MCP, screenshot, focus, open app)
160
+ - **`koru`** — `portal_capture.py` jako wzorzec dla Wayland screenshot
161
+
162
+ ## License
163
+
164
+ Licensed under Apache-2.0.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nlp2uri"
7
+ version = "0.1.1"
8
+ description = "Natural language to URI resolution and cross-platform local URI execution"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ authors = [{ name = "Semcod" }, {name = "Tom Sapletta",email = "tom@sapletta.com"}]
13
+ dependencies = []
14
+
15
+ [project.optional-dependencies]
16
+ dev = ["pytest>=8.0", "pytest-cov>=5.0",
17
+ "goal>=2.1.0",
18
+ "costs>=0.1.20",
19
+ "pfix>=0.1.60",
20
+ ]
21
+ linux = ["dbus-python>=1.3.2; sys_platform == 'linux'"]
22
+ windows = ["pywin32>=306; sys_platform == 'win32'"]
23
+ full = ["psutil>=6.0"]
24
+
25
+ [project.scripts]
26
+ nlp2uri = "nlp2uri.cli:main"
27
+
28
+ [tool.setuptools]
29
+ package-dir = { "" = "src" }
30
+
31
+ [tool.setuptools.packages.find]
32
+ where = ["src"]
33
+
34
+ [tool.pytest.ini_options]
35
+ testpaths = ["tests"]
36
+ addopts = "-q"
37
+ markers = [
38
+ "integration: Linux x-scheme-handler tests (set NLP2URI_INTEGRATION=1)",
39
+ ]
40
+
41
+ [tool.pfix]
42
+ # Self-healing Python configuration
43
+ model = "openrouter/qwen/qwen3-coder-next"
44
+ auto_apply = true
45
+ auto_install_deps = true
46
+ auto_restart = false
47
+ max_retries = 3
48
+ create_backups = false
49
+ git_auto_commit = false
50
+
51
+ [tool.pfix.runtime_todo]
52
+ enabled = true
53
+ todo_file = "TODO.md"
54
+ min_severity = "low"
55
+ deduplicate = true
56
+
57
+ [tool.costs]
58
+ # AI Cost tracking configuration
59
+ badge = true
60
+ update_readme = true
61
+ readme_path = "README.md"
62
+ default_model = "openrouter/qwen/qwen3-coder-next"
63
+ analysis_mode = "byok"
64
+ full_history = true
65
+ max_commits = 500
66
+
67
+ # Cost thresholds for badge colors (USD)
68
+ badge_color_thresholds = { low = 1.0, medium = 5.0, high = 10.0, critical = 50.0 }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ """Natural language to URI resolution and cross-platform execution."""
2
+
3
+ from nlp2uri.compile import compile_uri_to_actions
4
+ from nlp2uri.models import ActionResult, HostPlatform, NLP2URIResult, OSAction, UriIntent, UriSpec
5
+ from nlp2uri.resolve import nlp2uri, resolve_text
6
+ from nlp2uri.runtime import execute_uri, get_executor
7
+
8
+ __all__ = [
9
+ "ActionResult",
10
+ "HostPlatform",
11
+ "NLP2URIResult",
12
+ "OSAction",
13
+ "UriIntent",
14
+ "UriSpec",
15
+ "compile_uri_to_actions",
16
+ "execute_uri",
17
+ "get_executor",
18
+ "nlp2uri",
19
+ "resolve_text",
20
+ ]
21
+
22
+ __version__ = "0.1.1"