duckpack 0.2.0__tar.gz → 0.2.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.
- duckpack-0.2.2/.cargo/config.toml +2 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/.gitignore +2 -1
- {duckpack-0.2.0 → duckpack-0.2.2}/Cargo.lock +1 -1
- {duckpack-0.2.0 → duckpack-0.2.2}/Cargo.toml +1 -1
- {duckpack-0.2.0 → duckpack-0.2.2}/PKG-INFO +1 -1
- {duckpack-0.2.0 → duckpack-0.2.2}/pyproject.toml +1 -1
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/__init__.py +5 -40
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/notebook.py +25 -15
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/terminal.py +14 -7
- {duckpack-0.2.0 → duckpack-0.2.2}/src/diff.rs +1314 -719
- {duckpack-0.2.0 → duckpack-0.2.2}/src/engine.rs +716 -232
- duckpack-0.2.2/src/ide/editor.rs +685 -0
- duckpack-0.2.2/src/ide/explorer.rs +1091 -0
- duckpack-0.2.2/src/ide/mod.rs +4586 -0
- duckpack-0.2.2/src/ide/modals.rs +3737 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/src/main.rs +118 -395
- duckpack-0.2.2/src/python.rs +1264 -0
- duckpack-0.2.2/src/tui.rs +1252 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/tests/test_python_api.py +2 -2
- duckpack-0.2.0/src/ide.rs +0 -7328
- duckpack-0.2.0/src/python.rs +0 -1898
- duckpack-0.2.0/src/tui.rs +0 -519
- {duckpack-0.2.0 → duckpack-0.2.2}/.github/workflows/release.yml +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/LICENSE +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/README.md +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/duckpack_logo.png +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/__main__.py +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/_duckpack.pyi +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/cli.py +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/py.typed +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/python/duckpack/runner.py +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/scripts/scaffold_demo_project.sh +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/src/catalog.rs +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/src/lib.rs +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/src/query.rs +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/src/syntax.rs +0 -0
- {duckpack-0.2.0 → duckpack-0.2.2}/tests/v2_compat_test.rs +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "duckpack"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Declarative schema management, interactive terminal IDE, and in-memory inspection for DuckDB"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Benjamen Terry", email = "benjamenjterry@gmail.com" }]
|
|
@@ -18,7 +18,9 @@ from ._duckpack import (
|
|
|
18
18
|
build as _native_build,
|
|
19
19
|
init as _native_init,
|
|
20
20
|
get_target_config as _native_get_target_config,
|
|
21
|
+
discover_project_dir as _native_discover_project_dir,
|
|
21
22
|
SessionBridge,
|
|
23
|
+
__version__ as _native_version,
|
|
22
24
|
__duckdb_version__,
|
|
23
25
|
)
|
|
24
26
|
from .runner import InteractionRunner
|
|
@@ -29,45 +31,8 @@ def _is_db_conn(obj):
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def _discover_project_dir(start="."):
|
|
32
|
-
"""Auto-discovers the nearest declarative DuckPack project directory."""
|
|
33
|
-
|
|
34
|
-
start_path = Path(start).resolve()
|
|
35
|
-
except Exception:
|
|
36
|
-
return start
|
|
37
|
-
|
|
38
|
-
def is_proj(p):
|
|
39
|
-
return (
|
|
40
|
-
(p / "duckpack.toml").exists()
|
|
41
|
-
or (p / "queries").is_dir()
|
|
42
|
-
or (p / "tables").is_dir()
|
|
43
|
-
or (p / "schemas").is_dir()
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
if is_proj(start_path):
|
|
47
|
-
return str(start_path)
|
|
48
|
-
|
|
49
|
-
# 1. Candidate subdirectories
|
|
50
|
-
for cand in ["cli", "duckpack", "duckdb_project", "duckdb", "project", "demo_project"]:
|
|
51
|
-
sub = start_path / cand
|
|
52
|
-
if sub.is_dir() and is_proj(sub):
|
|
53
|
-
return str(sub)
|
|
54
|
-
|
|
55
|
-
# 2. Check parent directories up to filesystem root
|
|
56
|
-
curr = start_path.parent
|
|
57
|
-
while curr and curr != curr.parent:
|
|
58
|
-
if is_proj(curr):
|
|
59
|
-
return str(curr)
|
|
60
|
-
curr = curr.parent
|
|
61
|
-
|
|
62
|
-
# 3. Check sibling directories under parent (e.g. from 0.2.0/python to 0.2.0/cli)
|
|
63
|
-
parent = start_path.parent
|
|
64
|
-
if parent and parent != start_path:
|
|
65
|
-
for cand in ["cli", "duckpack", "duckdb_project", "duckdb", "project", "demo_project"]:
|
|
66
|
-
sib = parent / cand
|
|
67
|
-
if sib.is_dir() and is_proj(sib):
|
|
68
|
-
return str(sib)
|
|
69
|
-
|
|
70
|
-
return start
|
|
34
|
+
"""Auto-discovers the nearest declarative DuckPack project directory via the native Rust engine."""
|
|
35
|
+
return _native_discover_project_dir(str(start))
|
|
71
36
|
|
|
72
37
|
|
|
73
38
|
def _normalize_session_args(target, project_dir, database, catalog):
|
|
@@ -471,4 +436,4 @@ __all__ = [
|
|
|
471
436
|
"__duckdb_version__",
|
|
472
437
|
]
|
|
473
438
|
|
|
474
|
-
__version__ =
|
|
439
|
+
__version__ = _native_version
|
|
@@ -4,7 +4,9 @@ Provides rich, interactive rendering and terminal instructions for
|
|
|
4
4
|
Jupyter Notebooks, VS Code Interactive Window, and Dev Containers.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import html
|
|
7
8
|
import os
|
|
9
|
+
import shlex
|
|
8
10
|
import socket
|
|
9
11
|
import sys
|
|
10
12
|
from pathlib import Path
|
|
@@ -49,7 +51,8 @@ def stop_server() -> bool:
|
|
|
49
51
|
if target is not None and db_uri:
|
|
50
52
|
from ._duckpack import sync_back_host_temp_objects
|
|
51
53
|
sync_back_host_temp_objects(target)
|
|
52
|
-
|
|
54
|
+
safe_uri = str(db_uri).replace("'", "''")
|
|
55
|
+
target.execute(f"CALL quack_stop('{safe_uri}');")
|
|
53
56
|
return True
|
|
54
57
|
except Exception as e:
|
|
55
58
|
print(f"[DuckPack] Warning: Failed to stop background Quack server cleanly: {e}")
|
|
@@ -147,36 +150,41 @@ def render_notebook_card(
|
|
|
147
150
|
# Build the terminal command
|
|
148
151
|
cmd_parts = ["duckpack", mode]
|
|
149
152
|
if project_dir and project_dir != ".":
|
|
150
|
-
cmd_parts.extend(["-p", project_dir])
|
|
153
|
+
cmd_parts.extend(["-p", str(project_dir)])
|
|
151
154
|
if db_arg:
|
|
152
|
-
cmd_parts.extend(["-d", db_arg])
|
|
155
|
+
cmd_parts.extend(["-d", str(db_arg)])
|
|
153
156
|
if active_cat:
|
|
154
|
-
cmd_parts.extend(["--database", active_cat])
|
|
157
|
+
cmd_parts.extend(["--database", str(active_cat)])
|
|
155
158
|
if token_arg:
|
|
156
|
-
cmd_parts.extend(["--quack-token", token_arg])
|
|
159
|
+
cmd_parts.extend(["--quack-token", str(token_arg)])
|
|
157
160
|
if insecure or is_in_memory_bridge:
|
|
158
161
|
cmd_parts.append("--insecure")
|
|
159
162
|
if env:
|
|
160
|
-
cmd_parts.extend(["-e", env])
|
|
163
|
+
cmd_parts.extend(["-e", str(env)])
|
|
161
164
|
if mode == "apply":
|
|
162
165
|
cmd_parts.append("--interactive")
|
|
163
166
|
if force_drop:
|
|
164
167
|
cmd_parts.append("--force-drop")
|
|
165
168
|
|
|
166
|
-
terminal_cmd = " ".join(cmd_parts)
|
|
167
|
-
|
|
169
|
+
terminal_cmd = " ".join(shlex.quote(part) for part in cmd_parts)
|
|
170
|
+
escaped_terminal_cmd = html.escape(terminal_cmd, quote=True)
|
|
171
|
+
safe_cmd_attr = html.escape(terminal_cmd.replace("\\", "\\\\").replace("'", "\\'"), quote=True)
|
|
168
172
|
|
|
169
173
|
# Introspect tables for preview
|
|
170
174
|
tables = introspect_schema_summary(target)
|
|
171
175
|
table_rows_html = ""
|
|
172
176
|
if tables:
|
|
173
177
|
for t in tables:
|
|
178
|
+
t_name = html.escape(str(t["name"]), quote=True)
|
|
179
|
+
t_schema = html.escape(str(t["schema"]), quote=True)
|
|
180
|
+
t_cols = html.escape(str(t["columns"]), quote=True)
|
|
181
|
+
t_rows = html.escape(str(t["rows"]), quote=True)
|
|
174
182
|
table_rows_html += f"""
|
|
175
183
|
<tr style="border-bottom: 1px solid rgba(255,255,255,0.06);">
|
|
176
|
-
<td style="padding: 6px 10px; font-weight: 500;">{
|
|
177
|
-
<td style="padding: 6px 10px; opacity: 0.7;">{
|
|
178
|
-
<td style="padding: 6px 10px; text-align: right; font-family: monospace;">{
|
|
179
|
-
<td style="padding: 6px 10px; text-align: right; font-family: monospace;">{
|
|
184
|
+
<td style="padding: 6px 10px; font-weight: 500;">{t_name}</td>
|
|
185
|
+
<td style="padding: 6px 10px; opacity: 0.7;">{t_schema}</td>
|
|
186
|
+
<td style="padding: 6px 10px; text-align: right; font-family: monospace;">{t_cols}</td>
|
|
187
|
+
<td style="padding: 6px 10px; text-align: right; font-family: monospace;">{t_rows}</td>
|
|
180
188
|
</tr>
|
|
181
189
|
"""
|
|
182
190
|
preview_table_html = f"""
|
|
@@ -201,15 +209,17 @@ def render_notebook_card(
|
|
|
201
209
|
|
|
202
210
|
bridge_status_html = ""
|
|
203
211
|
if is_in_memory_bridge:
|
|
212
|
+
safe_db_arg = html.escape(str(db_arg), quote=True)
|
|
204
213
|
bridge_status_html = f"""
|
|
205
214
|
<div style="display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11px; opacity: 0.8;">
|
|
206
215
|
<span style="display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #10b981;"></span>
|
|
207
|
-
<span>Live Python session bridged on <code>{
|
|
216
|
+
<span>Live Python session bridged on <code>{safe_db_arg}</code></span>
|
|
208
217
|
<span>•</span>
|
|
209
218
|
<span>Stop with <code>duckpack.stop_server()</code></span>
|
|
210
219
|
</div>
|
|
211
220
|
"""
|
|
212
221
|
|
|
222
|
+
from . import __version__
|
|
213
223
|
title = "DuckPack Database Explorer" if mode == "explore" else "DuckPack Diff & Apply"
|
|
214
224
|
action_desc = "launch the full-screen terminal IDE" if mode == "explore" else "review diffs and apply migrations interactively"
|
|
215
225
|
|
|
@@ -233,7 +243,7 @@ def render_notebook_card(
|
|
|
233
243
|
<div style="font-size: 12px; opacity: 0.7;">Dev Container / Notebook Environment</div>
|
|
234
244
|
</div>
|
|
235
245
|
</div>
|
|
236
|
-
<span style="background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 12px;">
|
|
246
|
+
<span style="background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 12px;">v{__version__}</span>
|
|
237
247
|
</div>
|
|
238
248
|
|
|
239
249
|
<div style="background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.25); border-radius: 6px; padding: 10px 14px; font-size: 12px; line-height: 1.5; margin-bottom: 14px; color: #bae6fd;">
|
|
@@ -242,7 +252,7 @@ def render_notebook_card(
|
|
|
242
252
|
|
|
243
253
|
<div>
|
|
244
254
|
<div style="display: flex; align-items: center; justify-content: space-between; background: var(--vscode-terminal-background, #0d1117); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 6px; padding: 10px 14px;">
|
|
245
|
-
<code style="font-family: var(--vscode-editor-font-family, monospace); font-size: 12.5px; color: #38bdf8; word-break: break-all; user-select: all;">$ {
|
|
255
|
+
<code style="font-family: var(--vscode-editor-font-family, monospace); font-size: 12.5px; color: #38bdf8; word-break: break-all; user-select: all;">$ {escaped_terminal_cmd}</code>
|
|
246
256
|
<button onclick="navigator.clipboard.writeText('{safe_cmd_attr}').then(() => {{ this.innerText = '✓ Copied!'; setTimeout(() => this.innerText = '📋 Copy', 2000); }})" style="
|
|
247
257
|
background: rgba(255, 255, 255, 0.08);
|
|
248
258
|
border: 1px solid rgba(255, 255, 255, 0.16);
|
|
@@ -7,6 +7,7 @@ Notebooks or VS Code Interactive.
|
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
9
|
from pathlib import Path
|
|
10
|
+
import shlex
|
|
10
11
|
import shutil
|
|
11
12
|
import socket
|
|
12
13
|
import subprocess
|
|
@@ -142,25 +143,31 @@ def launch_terminal_window(
|
|
|
142
143
|
|
|
143
144
|
if active_cat:
|
|
144
145
|
cli_cmd.extend(["--database", active_cat])
|
|
145
|
-
if token_arg:
|
|
146
|
-
cli_cmd.extend(["--quack-token", token_arg])
|
|
147
146
|
if insecure_arg:
|
|
148
147
|
cli_cmd.append("--insecure")
|
|
149
148
|
if env:
|
|
150
149
|
cli_cmd.extend(["--env", env])
|
|
151
150
|
|
|
151
|
+
child_env = os.environ.copy()
|
|
152
|
+
if token_arg:
|
|
153
|
+
child_env["QUACK_TOKEN"] = str(token_arg)
|
|
154
|
+
|
|
152
155
|
# 3. Launch the terminal emulator
|
|
153
156
|
try:
|
|
154
157
|
if sys.platform == "darwin":
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
shell_parts = [shlex.quote(str(arg)) for arg in cli_cmd]
|
|
159
|
+
if token_arg:
|
|
160
|
+
shell_parts.insert(0, f"QUACK_TOKEN={shlex.quote(str(token_arg))}")
|
|
161
|
+
cmd_str = " ".join(shell_parts)
|
|
162
|
+
apple_escaped = cmd_str.replace("\\", "\\\\").replace('"', '\\"')
|
|
163
|
+
script = f'tell application "Terminal" to do script "{apple_escaped}"'
|
|
164
|
+
proc = subprocess.Popen(["osascript", "-e", script], env=child_env)
|
|
158
165
|
elif sys.platform == "win32" and "wt.exe" in term_prefix:
|
|
159
|
-
proc = subprocess.Popen(term_prefix + cli_cmd)
|
|
166
|
+
proc = subprocess.Popen(term_prefix + cli_cmd, env=child_env)
|
|
160
167
|
else:
|
|
161
168
|
# Linux (Ghostty, Foot, Kitty, Alacritty, etc.)
|
|
162
169
|
full_cmd = term_prefix + cli_cmd
|
|
163
|
-
proc = subprocess.Popen(full_cmd)
|
|
170
|
+
proc = subprocess.Popen(full_cmd, env=child_env)
|
|
164
171
|
|
|
165
172
|
session_type = "Diff & Apply Screen" if mode == "apply" else "Terminal IDE"
|
|
166
173
|
print(f"🦆 Launched DuckPack {session_type} in new window ({term_name})...")
|