@tiens.nguyen/gu-cli 1.0.905 → 1.0.907
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.
- package/browser-bridge.mjs +2 -1
- package/browser-chrome.mjs +5 -4
- package/browser-extension/actions.js +14 -3
- package/browser-extension/background.js +47 -11
- package/browser-extension/manifest.json +1 -1
- package/gonext_agent_chat.py +172 -9
- package/gu-cli.mjs +4 -2
- package/gu-repl.mjs +85 -36
- package/gu_browser.py +76 -3
- package/gu_mcp.py +23 -1
- package/mcp-command.mjs +4 -2
- package/mcp-config.mjs +22 -1
- package/model-doctor.mjs +78 -1
- package/package.json +1 -1
- package/skills/core/docx/SKILL.md +1 -1
- package/skills/core/docx/scripts/__pycache__/accept_changes.cpython-314.pyc +0 -0
- package/skills/core/docx/scripts/accept_changes.py +8 -6
- package/skills/core/docx/scripts/office/__pycache__/soffice.cpython-314.pyc +0 -0
- package/skills/core/docx/scripts/office/soffice.py +35 -3
- package/skills/core/pdf/SKILL.md +1 -1
- package/skills/core/pdf/scripts/convert_pdf_to_images.py +1 -0
- package/skills/core/pptx/SKILL.md +1 -1
- package/skills/core/pptx/scripts/office/__pycache__/soffice.cpython-314.pyc +0 -0
- package/skills/core/pptx/scripts/office/soffice.py +35 -3
- package/skills/core/xlsx/SKILL.md +1 -1
- package/skills/core/xlsx/scripts/__pycache__/recalc.cpython-314.pyc +0 -0
- package/skills/core/xlsx/scripts/office/__pycache__/soffice.cpython-314.pyc +0 -0
- package/skills/core/xlsx/scripts/office/soffice.py +35 -3
- package/skills/core/xlsx/scripts/recalc.py +6 -3
- package/skills.mjs +2 -1
- package/terminal-layout.mjs +23 -0
|
@@ -7,13 +7,15 @@ import argparse
|
|
|
7
7
|
import logging
|
|
8
8
|
import shutil
|
|
9
9
|
import subprocess
|
|
10
|
+
import tempfile
|
|
10
11
|
from pathlib import Path
|
|
11
12
|
|
|
12
|
-
from office.soffice import get_soffice_env
|
|
13
|
+
from office.soffice import get_soffice_env, soffice_binary
|
|
13
14
|
|
|
14
15
|
logger = logging.getLogger(__name__)
|
|
15
16
|
|
|
16
|
-
LIBREOFFICE_PROFILE = "
|
|
17
|
+
LIBREOFFICE_PROFILE = (Path(tempfile.gettempdir()) / "libreoffice_docx_profile").as_posix()
|
|
18
|
+
PROFILE_URI = Path(LIBREOFFICE_PROFILE).as_uri()
|
|
17
19
|
MACRO_DIR = f"{LIBREOFFICE_PROFILE}/user/basic/Standard"
|
|
18
20
|
|
|
19
21
|
ACCEPT_CHANGES_MACRO = """<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -56,9 +58,9 @@ def accept_changes(
|
|
|
56
58
|
return None, "Error: Failed to setup LibreOffice macro"
|
|
57
59
|
|
|
58
60
|
cmd = [
|
|
59
|
-
|
|
61
|
+
soffice_binary(),
|
|
60
62
|
"--headless",
|
|
61
|
-
f"-env:UserInstallation=
|
|
63
|
+
f"-env:UserInstallation={PROFILE_URI}",
|
|
62
64
|
"--norestore",
|
|
63
65
|
"vnd.sun.star.script:Standard.Module1.AcceptAllTrackedChanges?language=Basic&location=application",
|
|
64
66
|
str(output_path.absolute()),
|
|
@@ -98,9 +100,9 @@ def _setup_libreoffice_macro() -> bool:
|
|
|
98
100
|
if not macro_dir.exists():
|
|
99
101
|
subprocess.run(
|
|
100
102
|
[
|
|
101
|
-
|
|
103
|
+
soffice_binary(),
|
|
102
104
|
"--headless",
|
|
103
|
-
f"-env:UserInstallation=
|
|
105
|
+
f"-env:UserInstallation={PROFILE_URI}",
|
|
104
106
|
"--terminate_after_init",
|
|
105
107
|
],
|
|
106
108
|
capture_output=True,
|
|
@@ -17,16 +17,42 @@ callers that build their own argv (they must pass -env:UserInstallation too).
|
|
|
17
17
|
|
|
18
18
|
import contextlib
|
|
19
19
|
import os
|
|
20
|
+
import shutil
|
|
20
21
|
import socket
|
|
21
22
|
import subprocess
|
|
23
|
+
import sys
|
|
22
24
|
import tempfile
|
|
23
25
|
from collections.abc import Iterable
|
|
24
26
|
from pathlib import Path
|
|
25
27
|
|
|
26
28
|
|
|
29
|
+
def soffice_binary() -> str:
|
|
30
|
+
"""Path to soffice. On Windows (and macOS) LibreOffice is rarely on PATH, so look in its usual
|
|
31
|
+
install folders; fall back to the bare name so a missing install still raises FileNotFoundError."""
|
|
32
|
+
found = shutil.which("soffice")
|
|
33
|
+
if found:
|
|
34
|
+
return found
|
|
35
|
+
candidates = []
|
|
36
|
+
if sys.platform == "win32":
|
|
37
|
+
for var in ("ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"):
|
|
38
|
+
base = os.environ.get(var)
|
|
39
|
+
if base:
|
|
40
|
+
candidates.append(Path(base) / "LibreOffice" / "program" / "soffice.exe")
|
|
41
|
+
local = os.environ.get("LOCALAPPDATA")
|
|
42
|
+
if local:
|
|
43
|
+
candidates.append(Path(local) / "Programs" / "LibreOffice" / "program" / "soffice.exe")
|
|
44
|
+
elif sys.platform == "darwin":
|
|
45
|
+
candidates.append(Path("/Applications/LibreOffice.app/Contents/MacOS/soffice"))
|
|
46
|
+
for candidate in candidates:
|
|
47
|
+
if candidate.is_file():
|
|
48
|
+
return str(candidate)
|
|
49
|
+
return "soffice"
|
|
50
|
+
|
|
51
|
+
|
|
27
52
|
def get_soffice_env() -> dict:
|
|
28
53
|
env = os.environ.copy()
|
|
29
|
-
|
|
54
|
+
if sys.platform != "win32": # the headless "svp" VCL plugin does not exist on Windows builds
|
|
55
|
+
env["SAL_USE_VCLPLUGIN"] = "svp"
|
|
30
56
|
|
|
31
57
|
if _needs_shim():
|
|
32
58
|
shim = _ensure_shim()
|
|
@@ -43,7 +69,7 @@ def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess:
|
|
|
43
69
|
tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True)
|
|
44
70
|
)
|
|
45
71
|
args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args
|
|
46
|
-
return subprocess.run([
|
|
72
|
+
return subprocess.run([soffice_binary()] + args, env=get_soffice_env(), **kwargs)
|
|
47
73
|
|
|
48
74
|
|
|
49
75
|
|
|
@@ -51,8 +77,14 @@ _SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so"
|
|
|
51
77
|
|
|
52
78
|
|
|
53
79
|
def _needs_shim() -> bool:
|
|
80
|
+
# The shim is an LD_PRELOAD library: Linux only. Windows Python has no socket.AF_UNIX at all.
|
|
81
|
+
if sys.platform != "linux":
|
|
82
|
+
return False
|
|
83
|
+
af_unix = getattr(socket, "AF_UNIX", None)
|
|
84
|
+
if af_unix is None:
|
|
85
|
+
return False
|
|
54
86
|
try:
|
|
55
|
-
s = socket.socket(
|
|
87
|
+
s = socket.socket(af_unix, socket.SOCK_STREAM)
|
|
56
88
|
s.close()
|
|
57
89
|
return False
|
|
58
90
|
except OSError:
|
package/skills/core/pdf/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pdf
|
|
3
|
-
description: Use
|
|
3
|
+
description: Use for any PDF task: read or extract text and tables, merge, split, rotate, watermark, fill forms, encrypt, extract images, OCR, or create a PDF.
|
|
4
4
|
license: Complete terms in LICENSE.txt
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pptx
|
|
3
|
-
description: "Use
|
|
3
|
+
description: "Use when a .pptx or .potx is involved, or the user wants slides, a deck or a presentation: create, read, edit, combine, split, templates, speaker notes."
|
|
4
4
|
license: Complete terms in LICENSE.txt
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -17,16 +17,42 @@ callers that build their own argv (they must pass -env:UserInstallation too).
|
|
|
17
17
|
|
|
18
18
|
import contextlib
|
|
19
19
|
import os
|
|
20
|
+
import shutil
|
|
20
21
|
import socket
|
|
21
22
|
import subprocess
|
|
23
|
+
import sys
|
|
22
24
|
import tempfile
|
|
23
25
|
from collections.abc import Iterable
|
|
24
26
|
from pathlib import Path
|
|
25
27
|
|
|
26
28
|
|
|
29
|
+
def soffice_binary() -> str:
|
|
30
|
+
"""Path to soffice. On Windows (and macOS) LibreOffice is rarely on PATH, so look in its usual
|
|
31
|
+
install folders; fall back to the bare name so a missing install still raises FileNotFoundError."""
|
|
32
|
+
found = shutil.which("soffice")
|
|
33
|
+
if found:
|
|
34
|
+
return found
|
|
35
|
+
candidates = []
|
|
36
|
+
if sys.platform == "win32":
|
|
37
|
+
for var in ("ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"):
|
|
38
|
+
base = os.environ.get(var)
|
|
39
|
+
if base:
|
|
40
|
+
candidates.append(Path(base) / "LibreOffice" / "program" / "soffice.exe")
|
|
41
|
+
local = os.environ.get("LOCALAPPDATA")
|
|
42
|
+
if local:
|
|
43
|
+
candidates.append(Path(local) / "Programs" / "LibreOffice" / "program" / "soffice.exe")
|
|
44
|
+
elif sys.platform == "darwin":
|
|
45
|
+
candidates.append(Path("/Applications/LibreOffice.app/Contents/MacOS/soffice"))
|
|
46
|
+
for candidate in candidates:
|
|
47
|
+
if candidate.is_file():
|
|
48
|
+
return str(candidate)
|
|
49
|
+
return "soffice"
|
|
50
|
+
|
|
51
|
+
|
|
27
52
|
def get_soffice_env() -> dict:
|
|
28
53
|
env = os.environ.copy()
|
|
29
|
-
|
|
54
|
+
if sys.platform != "win32": # the headless "svp" VCL plugin does not exist on Windows builds
|
|
55
|
+
env["SAL_USE_VCLPLUGIN"] = "svp"
|
|
30
56
|
|
|
31
57
|
if _needs_shim():
|
|
32
58
|
shim = _ensure_shim()
|
|
@@ -43,7 +69,7 @@ def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess:
|
|
|
43
69
|
tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True)
|
|
44
70
|
)
|
|
45
71
|
args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args
|
|
46
|
-
return subprocess.run([
|
|
72
|
+
return subprocess.run([soffice_binary()] + args, env=get_soffice_env(), **kwargs)
|
|
47
73
|
|
|
48
74
|
|
|
49
75
|
|
|
@@ -51,8 +77,14 @@ _SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so"
|
|
|
51
77
|
|
|
52
78
|
|
|
53
79
|
def _needs_shim() -> bool:
|
|
80
|
+
# The shim is an LD_PRELOAD library: Linux only. Windows Python has no socket.AF_UNIX at all.
|
|
81
|
+
if sys.platform != "linux":
|
|
82
|
+
return False
|
|
83
|
+
af_unix = getattr(socket, "AF_UNIX", None)
|
|
84
|
+
if af_unix is None:
|
|
85
|
+
return False
|
|
54
86
|
try:
|
|
55
|
-
s = socket.socket(
|
|
87
|
+
s = socket.socket(af_unix, socket.SOCK_STREAM)
|
|
56
88
|
s.close()
|
|
57
89
|
return False
|
|
58
90
|
except OSError:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: xlsx
|
|
3
|
-
description: "Use
|
|
3
|
+
description: "Use when a spreadsheet (.xlsx, .xlsm, .csv, .tsv) is the input or output: open, edit, fix, clean, add formulas or charts, convert. Not for Word, HTML or the Google Sheets API."
|
|
4
4
|
license: Complete terms in LICENSE.txt
|
|
5
5
|
---
|
|
6
6
|
|
|
Binary file
|
|
@@ -17,16 +17,42 @@ callers that build their own argv (they must pass -env:UserInstallation too).
|
|
|
17
17
|
|
|
18
18
|
import contextlib
|
|
19
19
|
import os
|
|
20
|
+
import shutil
|
|
20
21
|
import socket
|
|
21
22
|
import subprocess
|
|
23
|
+
import sys
|
|
22
24
|
import tempfile
|
|
23
25
|
from collections.abc import Iterable
|
|
24
26
|
from pathlib import Path
|
|
25
27
|
|
|
26
28
|
|
|
29
|
+
def soffice_binary() -> str:
|
|
30
|
+
"""Path to soffice. On Windows (and macOS) LibreOffice is rarely on PATH, so look in its usual
|
|
31
|
+
install folders; fall back to the bare name so a missing install still raises FileNotFoundError."""
|
|
32
|
+
found = shutil.which("soffice")
|
|
33
|
+
if found:
|
|
34
|
+
return found
|
|
35
|
+
candidates = []
|
|
36
|
+
if sys.platform == "win32":
|
|
37
|
+
for var in ("ProgramFiles", "ProgramFiles(x86)", "ProgramW6432"):
|
|
38
|
+
base = os.environ.get(var)
|
|
39
|
+
if base:
|
|
40
|
+
candidates.append(Path(base) / "LibreOffice" / "program" / "soffice.exe")
|
|
41
|
+
local = os.environ.get("LOCALAPPDATA")
|
|
42
|
+
if local:
|
|
43
|
+
candidates.append(Path(local) / "Programs" / "LibreOffice" / "program" / "soffice.exe")
|
|
44
|
+
elif sys.platform == "darwin":
|
|
45
|
+
candidates.append(Path("/Applications/LibreOffice.app/Contents/MacOS/soffice"))
|
|
46
|
+
for candidate in candidates:
|
|
47
|
+
if candidate.is_file():
|
|
48
|
+
return str(candidate)
|
|
49
|
+
return "soffice"
|
|
50
|
+
|
|
51
|
+
|
|
27
52
|
def get_soffice_env() -> dict:
|
|
28
53
|
env = os.environ.copy()
|
|
29
|
-
|
|
54
|
+
if sys.platform != "win32": # the headless "svp" VCL plugin does not exist on Windows builds
|
|
55
|
+
env["SAL_USE_VCLPLUGIN"] = "svp"
|
|
30
56
|
|
|
31
57
|
if _needs_shim():
|
|
32
58
|
shim = _ensure_shim()
|
|
@@ -43,7 +69,7 @@ def run_soffice(args: Iterable[str], **kwargs) -> subprocess.CompletedProcess:
|
|
|
43
69
|
tempfile.TemporaryDirectory(prefix="lo_profile_", ignore_cleanup_errors=True)
|
|
44
70
|
)
|
|
45
71
|
args = [f"-env:UserInstallation={Path(profile).as_uri()}"] + args
|
|
46
|
-
return subprocess.run([
|
|
72
|
+
return subprocess.run([soffice_binary()] + args, env=get_soffice_env(), **kwargs)
|
|
47
73
|
|
|
48
74
|
|
|
49
75
|
|
|
@@ -51,8 +77,14 @@ _SHIM_SO = Path(tempfile.gettempdir()) / "lo_socket_shim.so"
|
|
|
51
77
|
|
|
52
78
|
|
|
53
79
|
def _needs_shim() -> bool:
|
|
80
|
+
# The shim is an LD_PRELOAD library: Linux only. Windows Python has no socket.AF_UNIX at all.
|
|
81
|
+
if sys.platform != "linux":
|
|
82
|
+
return False
|
|
83
|
+
af_unix = getattr(socket, "AF_UNIX", None)
|
|
84
|
+
if af_unix is None:
|
|
85
|
+
return False
|
|
54
86
|
try:
|
|
55
|
-
s = socket.socket(
|
|
87
|
+
s = socket.socket(af_unix, socket.SOCK_STREAM)
|
|
56
88
|
s.close()
|
|
57
89
|
return False
|
|
58
90
|
except OSError:
|
|
@@ -18,10 +18,13 @@ import time
|
|
|
18
18
|
import zipfile
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
|
|
21
|
-
from office.soffice import get_soffice_env, run_soffice
|
|
21
|
+
from office.soffice import get_soffice_env, run_soffice, soffice_binary
|
|
22
22
|
|
|
23
23
|
MACRO_FILENAME = "Module1.xba"
|
|
24
|
-
SOFFICE_MISSING =
|
|
24
|
+
SOFFICE_MISSING = (
|
|
25
|
+
"soffice not found; LibreOffice is required to recalculate "
|
|
26
|
+
"(Windows: winget install TheDocumentFoundation.LibreOffice, macOS: brew install --cask libreoffice)"
|
|
27
|
+
)
|
|
25
28
|
|
|
26
29
|
MAX_LOCATIONS = 100
|
|
27
30
|
|
|
@@ -198,7 +201,7 @@ def _recalc_with_profile(filename, abs_path, timeout, profile_dir: Path):
|
|
|
198
201
|
before = _stamp(abs_path)
|
|
199
202
|
|
|
200
203
|
cmd = [
|
|
201
|
-
|
|
204
|
+
soffice_binary(),
|
|
202
205
|
"--headless",
|
|
203
206
|
"--norestore",
|
|
204
207
|
f"-env:UserInstallation={profile_url}",
|
package/skills.mjs
CHANGED
|
@@ -46,7 +46,8 @@ export const SKILL_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
|
46
46
|
* (`overrides: "core"`), except the LOCKED ones other features depend on.
|
|
47
47
|
*/
|
|
48
48
|
export function coreSkillsDir() {
|
|
49
|
-
|
|
49
|
+
// GU_CORE_SKILLS_DIR: a test (or a packager) can point at another folder; unset = the package's own.
|
|
50
|
+
return process.env.GU_CORE_SKILLS_DIR || join(dirname(fileURLToPath(import.meta.url)), "skills", "core");
|
|
50
51
|
}
|
|
51
52
|
/** Core skills a personal skill may not replace: hooks and the resume flow rely on them. */
|
|
52
53
|
export const LOCKED_CORE_SKILLS = ["gu-session-memory-orchestration"];
|
package/terminal-layout.mjs
CHANGED
|
@@ -3369,6 +3369,29 @@ export function rankSlashCommands(cmds, typed) {
|
|
|
3369
3369
|
return scored.map((s) => s.c);
|
|
3370
3370
|
}
|
|
3371
3371
|
|
|
3372
|
+
/**
|
|
3373
|
+
* THE ROW ENTER WILL RUN WHEN THE USER HAS NOT PRESSED ↑/↓ (GH: "/mo" + Enter should be /model).
|
|
3374
|
+
* `cmds` is the ranked list from rankSlashCommands. Returns its index, or -1 for "run what was typed".
|
|
3375
|
+
* - the typed word is exactly a command name or alias → that command
|
|
3376
|
+
* - exactly ONE command has a name/alias that STARTS with it → that command
|
|
3377
|
+
* - several do ("/m" → /model, /mcp), arguments were typed ("/model x"), or none → -1
|
|
3378
|
+
*/
|
|
3379
|
+
export function autoSelectSlash(cmds, typed) {
|
|
3380
|
+
const parts = String(typed ?? "").trim().split(/\s+/);
|
|
3381
|
+
if (parts.length !== 1 || !parts[0].startsWith("/")) return -1;
|
|
3382
|
+
const word = parts[0].toLowerCase();
|
|
3383
|
+
if (word === "/") return -1;
|
|
3384
|
+
const all = (c) => [c.name, ...(c.aliases ?? [])].map((n) => String(n).toLowerCase());
|
|
3385
|
+
const list = cmds ?? [];
|
|
3386
|
+
const exact = list.findIndex((c) => all(c).includes(word));
|
|
3387
|
+
if (exact >= 0) return exact;
|
|
3388
|
+
const starts = [];
|
|
3389
|
+
list.forEach((c, i) => {
|
|
3390
|
+
if (all(c).some((n) => n.startsWith(word))) starts.push(i);
|
|
3391
|
+
});
|
|
3392
|
+
return starts.length === 1 ? starts[0] : -1;
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3372
3395
|
/**
|
|
3373
3396
|
* Which slice of the ranked list is on screen. `sel` -1 = nothing highlighted (window at the top).
|
|
3374
3397
|
* → { from, to, above, below, top } — above/below are how many are hidden on each side.
|