@allansantos-dev/smart-tool 0.9.81 → 0.9.82
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/CHANGELOG.md +64 -0
- package/NOTICE +1 -1
- package/README.md +41 -13
- package/agent_redirect.py +32 -0
- package/autostart.py +32 -25
- package/browser_bridge.py +320 -0
- package/browser_control.py +76 -39
- package/browser_service_client.py +1 -7
- package/client_hooks.py +41 -42
- package/code_graph.py +56 -15
- package/code_graph_java.mjs +21 -12
- package/code_health.py +14 -9
- package/codex_config.py +3 -0
- package/daemon_launcher.py +37 -5
- package/doc_candidates.py +63 -0
- package/doc_check.py +9 -3
- package/doc_extras.py +2 -3
- package/doc_insights.py +26 -2
- package/doc_prose.py +59 -11
- package/doc_registry.py +241 -0
- package/doc_scope.py +205 -39
- package/doc_turn.py +205 -0
- package/doc_validate.py +52 -9
- package/document_read.py +4 -2
- package/edit_shape.py +119 -0
- package/endpoint_sync.py +3 -21
- package/engine_home.py +95 -0
- package/hook_call.py +132 -0
- package/hook_decision.py +100 -6
- package/hooks/pretool_router.py +36 -30
- package/hooks/turn_end.py +40 -0
- package/index_views.py +5 -0
- package/install.py +24 -9
- package/lazy_mcp_proxy.py +10 -9
- package/local_embedder.py +8 -1
- package/locales/pt-BR.json +1 -2
- package/model_breaker.py +6 -5
- package/package.json +2 -2
- package/process_limits.py +17 -3
- package/project_identity.py +19 -1
- package/project_scan.py +98 -0
- package/scout_access.py +48 -0
- package/shell_reads.py +67 -0
- package/smart_tool_daemon.py +144 -39
- package/tray.py +31 -0
- package/venv_launch.py +67 -0
- package/version.py +1 -1
- package/web_adapters/node/engine-home.mjs +42 -0
- package/web_adapters/node/package-lock.json +13 -0
- package/web_adapters/node/package.json +1 -0
package/venv_launch.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Starts a Python of this installation's venv in one process.
|
|
2
|
+
|
|
3
|
+
On Windows a venv's ``Scripts\\python.exe`` and ``pythonw.exe`` are a redirector that starts the base interpreter as a
|
|
4
|
+
child and waits for it (cpython issue 161511, declined upstream), so every process of the product showed up twice. The
|
|
5
|
+
base interpreter started with ``__PYVENV_LAUNCHER__`` naming the venv's executable runs inside the venv by itself:
|
|
6
|
+
``sys.prefix`` and ``sys.executable`` are the venv's, and Python clears the variable at startup so children do not
|
|
7
|
+
inherit it. It is how ``multiprocessing`` starts its workers from a venv (bpo-35797).
|
|
8
|
+
"""
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
LAUNCHER_VARIABLE = "__PYVENV_LAUNCHER__"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class VenvLaunchError(RuntimeError):
|
|
16
|
+
"""The venv names a base interpreter that is not on disk."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def direct(executable):
|
|
20
|
+
"""Interpreter and environment additions that run a venv's executable without its redirector.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
executable: path of a venv's ``python.exe`` or ``pythonw.exe`` (or of any other interpreter).
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
``(interpreter, additions)``: the base interpreter of the same name, read from the ``home`` line of the venv's
|
|
27
|
+
``pyvenv.cfg``, and ``{LAUNCHER_VARIABLE: executable}``. Outside Windows, or for an interpreter that is not in
|
|
28
|
+
a venv, the executable itself and no additions.
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
VenvLaunchError: the venv's ``pyvenv.cfg`` names no ``home`` or a base interpreter that does not exist.
|
|
32
|
+
"""
|
|
33
|
+
executable = Path(executable)
|
|
34
|
+
config = executable.parent.parent / "pyvenv.cfg"
|
|
35
|
+
if os.name != "nt" or not config.is_file():
|
|
36
|
+
return str(executable), {}
|
|
37
|
+
settings = dict(line.split("=", 1) for line in config.read_text(encoding="utf-8").splitlines() if "=" in line)
|
|
38
|
+
home = next((value.strip() for key, value in settings.items() if key.strip().lower() == "home"), "")
|
|
39
|
+
base = Path(home) / executable.name
|
|
40
|
+
if not home or not base.is_file():
|
|
41
|
+
raise VenvLaunchError(f"The base Python of {config.parent} is missing ({base}); reinstall Smart Tool.")
|
|
42
|
+
return str(base), {LAUNCHER_VARIABLE: str(executable)}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def environment(additions):
|
|
46
|
+
"""The environment for a child that gets ``additions``: the current one plus them, or None (inherit) when empty."""
|
|
47
|
+
return {**os.environ, **additions} if additions else None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def hidden_run_vbs(executable, script, workdir=None):
|
|
51
|
+
"""VBScript that starts ``executable script`` hidden and without waiting, in one process.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
executable: the venv's interpreter to run (see ``direct``).
|
|
55
|
+
script: the Python file to run.
|
|
56
|
+
workdir: working directory of the child, or None to keep the script host's.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
The script text. WScript.Shell sets the variable in its own process environment, which ``Run`` passes on.
|
|
60
|
+
"""
|
|
61
|
+
interpreter, additions = direct(executable)
|
|
62
|
+
lines = ['Set shell = CreateObject("WScript.Shell")']
|
|
63
|
+
lines += [f'shell.Environment("Process")("{name}") = "{value}"' for name, value in additions.items()]
|
|
64
|
+
if workdir:
|
|
65
|
+
lines.append(f'shell.CurrentDirectory = "{workdir}"')
|
|
66
|
+
lines.append(f'shell.Run Chr(34) & "{interpreter}" & Chr(34) & " " & Chr(34) & "{script}" & Chr(34), 0, False')
|
|
67
|
+
return "\r\n".join(lines) + "\r\n"
|
package/version.py
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brings a shared engine of the engine registry up: installs it or updates it with the kit's SHA-256 and Ed25519 checks,
|
|
3
|
+
* starts it hidden and waits for its announce file. A home that already answers at the registry's version or newer is
|
|
4
|
+
* left alone, whichever way it was installed: the kit only knows the copy it installed itself and would replace a
|
|
5
|
+
* working one. Prints one JSON object on stdout and exits 0 also for a refusal, so the caller reads `ok` and `reason`.
|
|
6
|
+
*
|
|
7
|
+
* Usage: node engine-home.mjs <casa-de-embeddings|motor-de-grafo>
|
|
8
|
+
*/
|
|
9
|
+
import { ensureHome, discover, CASA, GRAFO } from "engine-kit/kit/client.mjs";
|
|
10
|
+
import { resolve } from "engine-kit/kit/resolve.mjs";
|
|
11
|
+
|
|
12
|
+
const ENGINES = { [CASA]: true, [GRAFO]: true };
|
|
13
|
+
|
|
14
|
+
const parts = (version) => String(version ?? "").split(".").map((piece) => Number.parseInt(piece, 10) || 0);
|
|
15
|
+
|
|
16
|
+
/** True when `version` is the same as `wanted` or newer. */
|
|
17
|
+
const atLeast = (version, wanted) => {
|
|
18
|
+
const [have, need] = [parts(version), parts(wanted)];
|
|
19
|
+
for (let index = 0; index < Math.max(have.length, need.length); index += 1) {
|
|
20
|
+
if ((have[index] ?? 0) !== (need[index] ?? 0)) { return (have[index] ?? 0) > (need[index] ?? 0); }
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const show = ({ shutdownToken, engine, ...visible }) => console.log(JSON.stringify(visible));
|
|
26
|
+
|
|
27
|
+
const name = process.argv[2];
|
|
28
|
+
if (!ENGINES[name]) {
|
|
29
|
+
console.log(JSON.stringify({ ok: false, reason: `unknown engine ${name}` }));
|
|
30
|
+
} else {
|
|
31
|
+
try {
|
|
32
|
+
const running = await discover(name);
|
|
33
|
+
const registry = running.ok ? await resolve(name) : null;
|
|
34
|
+
if (running.ok && registry?.ok && atLeast(running.version, registry.engine.version)) {
|
|
35
|
+
show({ ...running, installed: running.version });
|
|
36
|
+
} else {
|
|
37
|
+
show(await ensureHome(name));
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.log(JSON.stringify({ ok: false, reason: `${name}: ${error?.message ?? error}` }));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@angular/compiler": "20.3.0",
|
|
12
12
|
"@playwright/mcp": "0.0.83",
|
|
13
|
+
"engine-kit": "0.2.16",
|
|
13
14
|
"java-parser": "3.0.1",
|
|
14
15
|
"open-websearch": "2.1.11",
|
|
15
16
|
"typescript": "5.9.3"
|
|
@@ -1186,6 +1187,18 @@
|
|
|
1186
1187
|
"url": "https://github.com/fb55/encoding-sniffer?sponsor=1"
|
|
1187
1188
|
}
|
|
1188
1189
|
},
|
|
1190
|
+
"node_modules/engine-kit": {
|
|
1191
|
+
"version": "0.2.16",
|
|
1192
|
+
"resolved": "https://registry.npmjs.org/engine-kit/-/engine-kit-0.2.16.tgz",
|
|
1193
|
+
"integrity": "sha512-TFX/ojYSvW2Om/wL3hMuQ5Hcy2eV+mpNbPln1okculMucOT3cN68HMBYNpcA+5LftusrPVpjsiJfpi+csWL7rg==",
|
|
1194
|
+
"license": "MIT",
|
|
1195
|
+
"bin": {
|
|
1196
|
+
"engine-kit": "kit/cli.mjs"
|
|
1197
|
+
},
|
|
1198
|
+
"engines": {
|
|
1199
|
+
"node": ">=18"
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1189
1202
|
"node_modules/entities": {
|
|
1190
1203
|
"version": "4.5.0",
|
|
1191
1204
|
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|