@allansantos-dev/smart-tool 0.9.48 → 0.9.49
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 +9 -0
- package/README.md +1 -1
- package/locales/pt-BR.json +0 -1
- package/package.json +1 -1
- package/tray.py +49 -7
- package/version.py +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.49 - beta
|
|
4
|
+
|
|
5
|
+
- No more "Could not show a Smart Tool notice: [WinError 10061]" right after logon. The tray's notice loop asked the
|
|
6
|
+
daemon at once, using the address of the previous run from the registry, before the daemon was listening, and turned the
|
|
7
|
+
refused connection into a notification. Now a daemon that is not accepting connections yet (or no address yet) is asked
|
|
8
|
+
again every 15 s without showing anything; any other failure is written to `tray.log` in the data folder, once per
|
|
9
|
+
message, never shown as another notification. The same boot ordering applied to the update check: with no network yet
|
|
10
|
+
at logon it waited 24 h for the next try; it now retries every 5 min until npm answers (`tests/test_tray_notices.py`).
|
|
11
|
+
|
|
3
12
|
## 0.9.48 - beta
|
|
4
13
|
|
|
5
14
|
- Smart Tool spawns far fewer Git processes. A Git view (`index_views.describe`, `pin`) is now resolved once per
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ registered as the `playwright` server where this machine lets a browser be drive
|
|
|
17
17
|
An optional hook routes the agent's native Grep/Glob/Read/Bash/WebSearch/WebFetch calls to these tools when they
|
|
18
18
|
are cheaper, or just tells the agent what Smart Tool would do.
|
|
19
19
|
|
|
20
|
-
**Status:** 0.9.
|
|
20
|
+
**Status:** 0.9.49 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
|
|
21
21
|
|
|
22
22
|
## How it works
|
|
23
23
|
|
package/locales/pt-BR.json
CHANGED
|
@@ -864,7 +864,6 @@
|
|
|
864
864
|
"Could not open the projects: {error}": "Não foi possível abrir os projetos: {error}",
|
|
865
865
|
"Could not select the folder: {error}": "Não foi possível selecionar a pasta: {error}",
|
|
866
866
|
"Failed to change automatic start: {error}": "Não foi possível mudar a inicialização automática: {error}",
|
|
867
|
-
"Could not show a Smart Tool notice: {error}": "Não foi possível mostrar um aviso do Smart Tool: {error}",
|
|
868
867
|
"Could not save the update check: {error}": "Não foi possível salvar a verificação de atualização: {error}",
|
|
869
868
|
"Automatic update skipped: {error}": "Atualização automática ignorada: {error}",
|
|
870
869
|
"Smart Tool {version} is available: use \"Update to {version}\" in this menu.": "O Smart Tool {version} está disponível: use \"Atualizar para {version}\" neste menu.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allansantos-dev/smart-tool",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.49",
|
|
4
4
|
"description": "Local MCP server that gives coding agents (Claude Code, Codex) cheaper, sharper tools than their built-in search. Windows.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Allan Santos",
|
package/tray.py
CHANGED
|
@@ -12,6 +12,7 @@ import os
|
|
|
12
12
|
import sys
|
|
13
13
|
import threading
|
|
14
14
|
import time
|
|
15
|
+
import urllib.error
|
|
15
16
|
import urllib.request
|
|
16
17
|
import webbrowser
|
|
17
18
|
|
|
@@ -23,6 +24,7 @@ import autostart
|
|
|
23
24
|
import config
|
|
24
25
|
import daemon_launcher
|
|
25
26
|
import i18n
|
|
27
|
+
import paths
|
|
26
28
|
import setup_audit
|
|
27
29
|
import toast_notice
|
|
28
30
|
import update_check
|
|
@@ -31,6 +33,10 @@ import version
|
|
|
31
33
|
POLL_INTERVAL_S = 45
|
|
32
34
|
UPDATE_CHECK_INTERVAL_S = 24 * 3600
|
|
33
35
|
NOTICE_INTERVAL_S = 600
|
|
36
|
+
NOTICE_RETRY_S = 15
|
|
37
|
+
UPDATE_RETRY_S = 300
|
|
38
|
+
NOTICE_UNREACHABLE_LOG_S = 600
|
|
39
|
+
LOG_PATH = os.path.join(paths.DATA_DIR, "tray.log")
|
|
34
40
|
SETUP_URL = "http://127.0.0.1:8765/setup"
|
|
35
41
|
|
|
36
42
|
_STATE_LOCK = threading.Lock()
|
|
@@ -165,22 +171,55 @@ def _show_notices(icon, notices):
|
|
|
165
171
|
tag="setup-audit:" + row["project"])
|
|
166
172
|
|
|
167
173
|
|
|
174
|
+
def _log(text):
|
|
175
|
+
"""Appends a line to `tray.log` in the data folder: what the tray cannot tell with a notification (a notice that could
|
|
176
|
+
not be fetched or shown) is kept where the user can read it, never turned into another notification."""
|
|
177
|
+
try:
|
|
178
|
+
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
|
179
|
+
with open(LOG_PATH, "a", encoding="utf-8") as log:
|
|
180
|
+
log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} {text}\n")
|
|
181
|
+
except OSError:
|
|
182
|
+
pass # no console and no other channel here; a full disk must not kill the notice thread
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _daemon_not_ready(exc):
|
|
186
|
+
"""The daemon is not accepting connections yet (refused, reset or no answer in time), as right after boot, when the
|
|
187
|
+
registry still holds the address of the previous run. An HTTP answer, even an error, is not that."""
|
|
188
|
+
if isinstance(exc, urllib.error.HTTPError):
|
|
189
|
+
return False
|
|
190
|
+
reason = exc.reason if isinstance(exc, urllib.error.URLError) else exc
|
|
191
|
+
return isinstance(reason, (ConnectionError, TimeoutError))
|
|
192
|
+
|
|
193
|
+
|
|
168
194
|
def _notice_loop(icon):
|
|
169
195
|
"""Asks the daemon every 10 minutes whether a toast is due. The daemon decides (once a day per notice) and marks it
|
|
170
|
-
announced, so a restart of the tray never repeats one.
|
|
196
|
+
announced, so a restart of the tray never repeats one. While the daemon is still starting the question is asked again
|
|
197
|
+
every few seconds and nothing is shown: the tray icon already says "starting". Any other failure goes to `tray.log`."""
|
|
198
|
+
waiting_since = None
|
|
171
199
|
while True:
|
|
200
|
+
delay = NOTICE_INTERVAL_S
|
|
172
201
|
try:
|
|
173
202
|
daemon_url = (daemon_launcher.read_registry() or {}).get("url")
|
|
174
203
|
if daemon_url:
|
|
175
204
|
request = urllib.request.Request(daemon_url.rstrip("/") + "/setup/notices", data=b"{}", method="POST",
|
|
176
205
|
headers={"Content-Type": "application/json"})
|
|
177
206
|
with urllib.request.urlopen(request, timeout=60) as response:
|
|
178
|
-
|
|
207
|
+
notices = json.load(response)
|
|
208
|
+
waiting_since = None
|
|
209
|
+
_show_notices(icon, notices)
|
|
210
|
+
else:
|
|
211
|
+
delay = NOTICE_RETRY_S
|
|
179
212
|
except Exception as exc:
|
|
180
|
-
if
|
|
213
|
+
if _daemon_not_ready(exc):
|
|
214
|
+
delay = NOTICE_RETRY_S
|
|
215
|
+
waiting_since = waiting_since if waiting_since is not None else time.monotonic()
|
|
216
|
+
if time.monotonic() - waiting_since >= NOTICE_UNREACHABLE_LOG_S and not _state.get("notice_unreachable"):
|
|
217
|
+
_state["notice_unreachable"] = True
|
|
218
|
+
_log(f"notices: the daemon has not answered for {NOTICE_UNREACHABLE_LOG_S // 60} min: {exc}")
|
|
219
|
+
elif str(exc) != _state.get("notice_error"):
|
|
181
220
|
_state["notice_error"] = str(exc)
|
|
182
|
-
|
|
183
|
-
time.sleep(
|
|
221
|
+
_log(f"notices: could not fetch or show them: {type(exc).__name__}: {exc}")
|
|
222
|
+
time.sleep(delay)
|
|
184
223
|
|
|
185
224
|
|
|
186
225
|
def _announce_start(icon):
|
|
@@ -197,17 +236,20 @@ def _announce_start(icon):
|
|
|
197
236
|
|
|
198
237
|
|
|
199
238
|
def _update_loop(icon):
|
|
200
|
-
"""Checks npm at start and every 24 h
|
|
239
|
+
"""Checks npm at start and every 24 h (every 5 min while npm cannot be reached, as when the network is not up yet right
|
|
240
|
+
after boot; nothing is shown for that). A newer version is installed right away when automatic updates are on (once
|
|
201
241
|
per version, again 24 h after a failed try); otherwise the user is told and the menu offers it."""
|
|
202
242
|
try:
|
|
203
243
|
_announce_start(icon)
|
|
204
244
|
except Exception as exc:
|
|
205
245
|
_notify(icon, "Could not read the update state: {error}", error=exc)
|
|
206
246
|
while True:
|
|
247
|
+
unreachable = False
|
|
207
248
|
try:
|
|
208
249
|
latest = update_check.newer_version()
|
|
209
250
|
except Exception:
|
|
210
251
|
latest = None
|
|
252
|
+
unreachable = True
|
|
211
253
|
else:
|
|
212
254
|
try:
|
|
213
255
|
update_check.record_check(latest)
|
|
@@ -228,7 +270,7 @@ def _update_loop(icon):
|
|
|
228
270
|
elif not known:
|
|
229
271
|
_notify(icon, "Smart Tool {version} is available: use \"Update to {version}\" in this menu.",
|
|
230
272
|
version=latest)
|
|
231
|
-
time.sleep(UPDATE_CHECK_INTERVAL_S)
|
|
273
|
+
time.sleep(UPDATE_RETRY_S if unreachable else UPDATE_CHECK_INTERVAL_S)
|
|
232
274
|
|
|
233
275
|
|
|
234
276
|
def _update_label(item):
|
package/version.py
CHANGED