Natural language to URI resolution and cross-platform local URI execution
Project description
nlp2uri
AI Cost Tracking
- 🤖 LLM usage: $0.1500 (1 commits)
- 👤 Human dev: ~$100 (1.0h @ $100/h, 30min dedup)
Generated on 2026-06-06 using openrouter/qwen/qwen3-coder-next
Python library and CLI — kompilator NL → URI → akcje OS dla operacji desktopowych.
Wejście (naturalny język):
- „otwórz VS Code w folderze ~/projekty/nlp2uri”
- „zrób screenshot aktywnego okna przeglądarki”
- „otwórz plik invoice-2025.pdf”
Wyjście:
- Abstrakcyjny URI (RFC 3986, niezależny od OS)
- Plan akcji
OSAction[]— konkretne komendy per platforma - (Opcjonalnie) wykonanie lub payload MCP (
text/uri-list)
Architektura
flowchart LR
NL[Natural language] --> PARSE[parse_nl]
PARSE --> INTENT[UriIntent + slots]
INTENT --> BUILD[schemes/build]
BUILD --> SPEC[UriSpec abstract URI]
SPEC --> COMPILE[compile_uri_to_actions]
COMPILE --> ACTIONS[OSAction plan]
ACTIONS --> EXEC[execute_uri / MCP]
Warstwy
| Warstwa | Moduł | Opis |
|---|---|---|
| NLP → intencja | parse_nl |
Heurystyki EN + PL → UriIntent |
| Intencja → URI | schemes/* |
Abstrakcyjne schemy OS-neutral |
| URI → OS | compile |
compile_uri_to_actions() |
| Wykonanie | runtime |
subprocess / dry-run |
| MCP | mcp |
text/uri-list, tool payloads |
Abstrakcyjne schemy URI
| Scheme | Przykład | Znaczenie |
|---|---|---|
app:// |
app://vscode/open?path=/home/tom/... |
Otwórz aplikację / IDE |
app://file/open |
app://file/open?path=/tmp/x.pdf |
Otwórz plik |
desktop-screenshot:// |
desktop-screenshot://window?title=Chrome&mode=active |
Screenshot okna/ekranu |
desktop-window:// |
desktop-window://focus?name=slack |
Fokus okna |
| natywne | vscode://, cursor://, file://, ms-settings: |
Passthrough do handlera OS |
Metadata native_uri zawiera deep-link IDE (vscode://file/...) gdy istnieje.
Quick start
pip install -e ".[dev]"
# Pełny plan: URI + OSActions
nlp2uri plan "otwórz vscode w folderze ~/github/semcod/nlp2uri" --platform linux --json
# Tylko URI
nlp2uri resolve "zrób screenshot aktywnego okna przeglądarki" --platform linux --json
# URI → komendy
nlp2uri compile "desktop-screenshot://window?title=Chrome&mode=active" --platform linux --json
# Dry-run (bezpieczne w CI/Docker)
nlp2uri execute "open firefox" --platform linux --dry-run
Python API
from nlp2uri import nlp2uri, compile_uri_to_actions, execute_uri
from nlp2uri.models import HostPlatform
plan = nlp2uri(
"otwórz vscode w folderze /tmp/foo",
os=HostPlatform.LINUX,
)
print(plan.uri) # app://vscode/open?path=/tmp/foo
print(plan.intent) # open_app
print(plan.slots) # {"app": "vscode", "resource": "/tmp/foo", ...}
print(plan.actions[0].argv()) # ['xdg-open', 'vscode://file/tmp/foo']
result = execute_uri(plan.uri, platform=HostPlatform.LINUX, dry_run=True)
MCP server
from nlp2uri.mcp import tool_resolve_desktop_action, tool_execute_desktop_uri
# Tool 1: NL → URI + plan (zwraca text/uri-list)
tool_resolve_desktop_action("screenshot window titled Firefox", platform=HostPlatform.LINUX)
# Tool 2: wykonaj URI (lub dry-run)
tool_execute_desktop_uri("desktop-screenshot://screen", platform=HostPlatform.LINUX, dry_run=True)
Host MCP może mapować desktop-screenshot://... na backend typu mcp-desktop-pro zamiast bezpośredniego subprocess.
Standardy
| Standard | Rola |
|---|---|
| RFC 3986 | Składnia URI (scheme, path, query) |
| RFC 8089 | file:// |
| RFC 9110 | http(s):// |
| Freedesktop Desktop Entry | .desktop, x-scheme-handler/<scheme> |
| XDG Desktop Portal | Screenshot Wayland |
| Windows URI activation | ms-settings:, rejestracja schemów |
| macOS URL Schemes | CFBundleURLSchemes w Info.plist |
MCP text/uri-list |
Lista URI dla hosta / MCP Apps |
Przydatne biblioteki
| Biblioteka | Kiedy |
|---|---|
urllib.parse, webbrowser, subprocess |
Już używane (stdlib) |
psutil |
PID → okno |
pyxdg |
Parsowanie .desktop |
dbus-python + PyGObject |
XDG Portal screenshot |
pywin32 |
Win32 SetForegroundWindow |
pyobjc / Quartz |
macOS window ID |
spaCy / transformers |
Zamiast heurystyk regex |
nlp2dsl / nlp2cmd-intent |
IntentIR z LLM (jak nlpshim) |
Testy i Docker
python -m pytest
docker compose build && docker compose run --rm nlp2uri-test
bash examples/run_all.sh
W Dockerze:
- unit: NLP → URI →
OSAction - integracja: rejestracja
testapp://przez.desktop+xdg-open(NLP2URI_INTEGRATION=1)
Relacja z ekosystemem Semcod
nlpshim— NLP → DSL / workflownlp2uri— NLP → URI → akcje desktopowe (MCP, screenshot, focus, open app)koru—portal_capture.pyjako wzorzec dla Wayland screenshot
License
Licensed under Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nlp2uri-0.1.1.tar.gz.
File metadata
- Download URL: nlp2uri-0.1.1.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfe2cce3bcff9bae4f36ebe1a3c7c5d72f5fc1ee41c82ac094918942ff814dc9
|
|
| MD5 |
5c33bea6ade5c89cd746a244766e321d
|
|
| BLAKE2b-256 |
af2291ccab21545e88e53c6df6055a3eb6720ab93c67917e80b9dd3cdaf61418
|
File details
Details for the file nlp2uri-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nlp2uri-0.1.1-py3-none-any.whl
- Upload date:
- Size: 29.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dcc019a66c125bd8307dcd6d12978f9fc36b899367ed9f7d323523fe44892e5
|
|
| MD5 |
f74c111aa621fc3733bc300f12246cf1
|
|
| BLAKE2b-256 |
ee02c5ea77920a694c3889165a1658c20ede902b6e37d76788817777fd5831f3
|