@allansantos-dev/smart-tool 0.9.49 → 0.9.50
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/package.json +1 -1
- package/toast_notice.py +13 -1
- package/tray.py +14 -6
- package/version.py +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.50 - beta
|
|
4
|
+
|
|
5
|
+
- Windows refused the setup-audit toast of a project whose path made the toast tag longer than 64 characters
|
|
6
|
+
(`ToastNotification.Tag` limit since the Creators Update); before 0.9.49 that refusal became a second notification
|
|
7
|
+
"Could not show a Smart Tool notice". `toast_notice.show` now fits a longer tag to 64 characters (its start plus a hash
|
|
8
|
+
of the whole, so each project still replaces its own toast), and each notice in `_show_notices` is shown on its own: a
|
|
9
|
+
refused one goes to `tray.log` and the next ones are still shown. The toast script no longer writes PowerShell's
|
|
10
|
+
progress records, so a refusal in the log reads as the error itself (`tests/test_tray_notices.py`).
|
|
11
|
+
|
|
3
12
|
## 0.9.49 - beta
|
|
4
13
|
|
|
5
14
|
- No more "Could not show a Smart Tool notice: [WinError 10061]" right after logon. The tray's notice loop asked the
|
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.50 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
|
|
21
21
|
|
|
22
22
|
## How it works
|
|
23
23
|
|
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.50",
|
|
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/toast_notice.py
CHANGED
|
@@ -7,6 +7,7 @@ only HKCU keys (no admin): one AppUserModelId key (name and icon of the toast) a
|
|
|
7
7
|
write the config file, never state held by the tray.
|
|
8
8
|
"""
|
|
9
9
|
import base64
|
|
10
|
+
import hashlib
|
|
10
11
|
import os
|
|
11
12
|
import subprocess
|
|
12
13
|
import sys
|
|
@@ -15,10 +16,12 @@ from xml.sax.saxutils import quoteattr, escape
|
|
|
15
16
|
|
|
16
17
|
APP_ID = "SmartTool.Notifications"
|
|
17
18
|
PROTOCOL = "smart-tool-action"
|
|
19
|
+
TAG_MAX = 64
|
|
18
20
|
ACTION_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "notice_action.py")
|
|
19
21
|
|
|
20
22
|
_SHOW_SCRIPT = r"""
|
|
21
23
|
$ErrorActionPreference = 'Stop'
|
|
24
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
22
25
|
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
|
23
26
|
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
|
24
27
|
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
|
@@ -84,6 +87,15 @@ def toast_xml(title, lines, buttons):
|
|
|
84
87
|
+ (f'<actions>{actions}</actions>' if actions else '') + '</toast>')
|
|
85
88
|
|
|
86
89
|
|
|
90
|
+
def _fit_tag(tag):
|
|
91
|
+
"""Windows refuses a toast whose Tag is longer than 64 characters. A longer tag (one built from a project path) keeps
|
|
92
|
+
its start and ends in a hash of the whole, so each project still replaces its own toast."""
|
|
93
|
+
if len(tag) <= TAG_MAX:
|
|
94
|
+
return tag
|
|
95
|
+
digest = hashlib.sha256(tag.encode("utf-8")).hexdigest()[:24]
|
|
96
|
+
return tag[:TAG_MAX - len(digest) - 1] + "~" + digest
|
|
97
|
+
|
|
98
|
+
|
|
87
99
|
def show(title, lines, buttons, tag=None):
|
|
88
100
|
"""Shows the toast; raises RuntimeError with PowerShell's message when Windows refuses it."""
|
|
89
101
|
if sys.platform != "win32":
|
|
@@ -91,7 +103,7 @@ def show(title, lines, buttons, tag=None):
|
|
|
91
103
|
register()
|
|
92
104
|
script = base64.b64encode(_SHOW_SCRIPT.encode("utf-16-le")).decode("ascii")
|
|
93
105
|
env = {**os.environ, "SMART_TOOL_TOAST_XML": toast_xml(title, lines, buttons),
|
|
94
|
-
"SMART_TOOL_TOAST_APPID": APP_ID, "SMART_TOOL_TOAST_TAG": tag or ""}
|
|
106
|
+
"SMART_TOOL_TOAST_APPID": APP_ID, "SMART_TOOL_TOAST_TAG": _fit_tag(tag or "")}
|
|
95
107
|
done = subprocess.run(
|
|
96
108
|
["powershell.exe", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", script],
|
|
97
109
|
env=env, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30,
|
package/tray.py
CHANGED
|
@@ -145,6 +145,14 @@ def _poll_loop(icon):
|
|
|
145
145
|
time.sleep(POLL_INTERVAL_S)
|
|
146
146
|
|
|
147
147
|
|
|
148
|
+
def _toast(title, lines, buttons, tag):
|
|
149
|
+
"""One notice: a toast Windows refuses goes to `tray.log` and does not keep the next notices from being shown."""
|
|
150
|
+
try:
|
|
151
|
+
toast_notice.show(title, lines, buttons, tag=tag)
|
|
152
|
+
except Exception as exc:
|
|
153
|
+
_log(f"notice {tag}: {type(exc).__name__}: {exc}")
|
|
154
|
+
|
|
155
|
+
|
|
148
156
|
def _show_notices(icon, notices):
|
|
149
157
|
"""Shows a toast for each pending notice: the new-default-models offer, each model over the failure limit and each
|
|
150
158
|
project whose scheduled setup audit found new errors or warnings."""
|
|
@@ -152,23 +160,23 @@ def _show_notices(icon, notices):
|
|
|
152
160
|
if offer:
|
|
153
161
|
lines = [f"{role}: {change['current']} -> {change['new']}" for role, change in offer["changes"].items()]
|
|
154
162
|
nonce = offer["nonce"]
|
|
155
|
-
|
|
163
|
+
_toast(i18n.t("Smart Tool has new recommended models"), lines, [
|
|
156
164
|
(i18n.t("Apply now"), toast_notice.action_uri("models-apply", n=nonce)),
|
|
157
165
|
(i18n.t("Don't show again"), toast_notice.action_uri("models-decline", n=nonce)),
|
|
158
|
-
],
|
|
166
|
+
], "models-upgrade")
|
|
159
167
|
for row in notices.get("failing") or []:
|
|
160
168
|
last = row.get("last_error") or i18n.t("see the failure log in the settings")
|
|
161
|
-
|
|
169
|
+
_toast(
|
|
162
170
|
i18n.t("{model} is failing", model=row["model"]),
|
|
163
171
|
[i18n.t("{errors} of {calls} calls failed in 24 h as {role}.", errors=row["errors"], calls=row["calls"],
|
|
164
172
|
role=row["role"]), last[:160]],
|
|
165
173
|
[(i18n.t("Switch model"), toast_notice.action_uri("open-setup", section="models")),
|
|
166
174
|
(i18n.t("Mute 7 days"), toast_notice.action_uri("mute-model", model=row["model"]))],
|
|
167
|
-
|
|
175
|
+
"model-failing:" + row["model"])
|
|
168
176
|
for row in notices.get("audit") or []:
|
|
169
177
|
title, lines = setup_audit.toast_text(row)
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
_toast(title, lines, [(i18n.t("Open the audit"), toast_notice.action_uri("open-setup", section="audit"))],
|
|
179
|
+
"setup-audit:" + row["project"])
|
|
172
180
|
|
|
173
181
|
|
|
174
182
|
def _log(text):
|
package/version.py
CHANGED