@allansantos-dev/smart-tool 0.9.81 → 0.9.83
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 +115 -0
- package/NOTICE +1 -1
- package/README.md +73 -14
- package/affected_tests.py +9 -8
- 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 +66 -21
- package/code_graph_java.mjs +21 -12
- package/code_health.py +14 -9
- package/codex_config.py +3 -0
- package/commit_check.py +184 -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_converter.py +4 -4
- package/document_read.py +19 -11
- package/document_url.py +107 -0
- package/edit_shape.py +119 -0
- package/endpoint_sync.py +3 -21
- package/engine_home.py +95 -0
- package/hook_call.py +133 -0
- package/hook_decision.py +142 -7
- package/hooks/pre_commit.py +45 -0
- 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/release_notes.py +125 -0
- package/rename_preview.py +95 -0
- package/requester.py +1 -1
- package/scout_access.py +48 -0
- package/shell_reads.py +67 -0
- package/smart_tool_daemon.py +245 -50
- 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/web_fetch_many.py +61 -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",
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""web_fetch_many: several URLs with one prompt in one call, each read through the single-URL path of web_fetch.
|
|
2
|
+
|
|
3
|
+
The caller passes that path as `fetch_one(url, prompt)`: it returns the text of one URL or raises. Every URL is read on
|
|
4
|
+
its own (cache, failure memory, browser fallback, address guard and answer of web_fetch), so one URL that fails is
|
|
5
|
+
reported with its reason next to the others instead of failing or answering for them. A small pool keeps the number of
|
|
6
|
+
pages read at once, and so of browsers started, low.
|
|
7
|
+
"""
|
|
8
|
+
import concurrent.futures
|
|
9
|
+
import contextvars
|
|
10
|
+
|
|
11
|
+
import web_fetch
|
|
12
|
+
|
|
13
|
+
MAX_URLS = 8
|
|
14
|
+
WORKERS = 4
|
|
15
|
+
MAX_URL_CHARS = 2000
|
|
16
|
+
MAX_PROMPT_CHARS = 4000
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def check(urls, prompt):
|
|
20
|
+
"""Raises ValueError unless `urls` is a list of 1 to MAX_URLS non-empty strings and `prompt` a non-empty string, so
|
|
21
|
+
nothing is read for a malformed call."""
|
|
22
|
+
if not isinstance(urls, list) or not urls:
|
|
23
|
+
raise ValueError(f"web_fetch_many requires 'urls' (a list of 1 to {MAX_URLS} URLs)")
|
|
24
|
+
if len(urls) > MAX_URLS:
|
|
25
|
+
raise ValueError(f"web_fetch_many reads at most {MAX_URLS} URLs per call, got {len(urls)}: split them in calls "
|
|
26
|
+
f"of {MAX_URLS} or fewer")
|
|
27
|
+
if not all(isinstance(url, str) and url.strip() and len(url) <= MAX_URL_CHARS for url in urls):
|
|
28
|
+
raise ValueError(f"web_fetch_many requires every URL to be a non-empty string of at most {MAX_URL_CHARS} "
|
|
29
|
+
"characters")
|
|
30
|
+
if not isinstance(prompt, str) or not prompt.strip() or len(prompt) > MAX_PROMPT_CHARS:
|
|
31
|
+
raise ValueError(f"web_fetch_many requires 'prompt' (at most {MAX_PROMPT_CHARS} characters)")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def read_many(urls, prompt, fetch_one):
|
|
35
|
+
"""One result per entry of `urls`, in the same order: `{"url", "ok": True, "text"}` or `{"url", "ok": False,
|
|
36
|
+
"error"}`. A URL repeated (same address once the fragment and the outer spaces are dropped) is read once and
|
|
37
|
+
every position gets its result. Each read runs in a copy of the caller's context, so the request attribution and
|
|
38
|
+
the model-failure collection of the tool call follow it into the pool."""
|
|
39
|
+
keys = [web_fetch.normalize(url) for url in urls]
|
|
40
|
+
distinct = list(dict.fromkeys(keys))
|
|
41
|
+
with concurrent.futures.ThreadPoolExecutor(min(WORKERS, len(distinct)), thread_name_prefix="web-fetch-many") as pool:
|
|
42
|
+
futures = {key: pool.submit(contextvars.copy_context().run, fetch_one, key, prompt) for key in distinct}
|
|
43
|
+
outcomes = {key: _outcome(future) for key, future in futures.items()}
|
|
44
|
+
return [{"url": url, **outcomes[key]} for url, key in zip(urls, keys)]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _outcome(future):
|
|
48
|
+
try:
|
|
49
|
+
return {"ok": True, "text": future.result()}
|
|
50
|
+
except Exception as exc:
|
|
51
|
+
return {"ok": False, "error": str(exc) or type(exc).__name__}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def render(results):
|
|
55
|
+
"""The text the agent reads: a count line, then one numbered block per URL with its answer or `ERROR: reason`."""
|
|
56
|
+
failed = sum(not result["ok"] for result in results)
|
|
57
|
+
blocks = [f"web_fetch_many: {len(results)} URLs, {len(results) - failed} read, {failed} failed."]
|
|
58
|
+
for number, result in enumerate(results, 1):
|
|
59
|
+
body = result["text"] if result["ok"] else f"ERROR: {result['error']}"
|
|
60
|
+
blocks.append(f"[{number}/{len(results)}] {result['url']}\n{body}")
|
|
61
|
+
return "\n\n".join(blocks)
|