@allansantos-dev/smart-tool 0.9.52 → 0.9.53

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.53 - beta
4
+
5
+ - An update started in the first minutes after a release finds it. The update screen and the manual command in the
6
+ update notices run `npx --yes --prefer-online @allansantos-dev/smart-tool@<version> install`: without
7
+ `--prefer-online`, npm answered from the version list in its cache, fetched before the release, and the update ended
8
+ in `npm error code ETARGET ... No matching version found` although the tray had already seen that version on npm
9
+ (`tests/test_update_splash.py`, `tests/test_update_check.py`, `tests/test_node_locator.py`). The README and the
10
+ wrapper usage text (`npx @allansantos-dev/smart-tool`) say so for an update by hand.
11
+ - The product page is published only once npm lists the version it shows: `release/pages.py wait-npm` reads the
12
+ registry until the version in `version.py` is there (up to 60 min, then the Pages job fails) and runs before
13
+ `publish`. The page used to go live from the push to `main` and right after the release pushed the package, minutes
14
+ before npm served it, so its pinned install command ended in "No matching version found" (`tests/test_pages.py`).
15
+ - `tray.log` and `notice-actions.log` keep one previous generation (`.1`) past 256 KB and write each entry on one line:
16
+ the link a toast button hands to `notice_action.py` can no longer add lines of its own. A Windows notification the
17
+ update window could not show is also written to `update.log`, not only to the window that closes by itself
18
+ (`tests/test_tray_notices.py`, `tests/test_model_upgrade.py`, `tests/test_update_splash.py`).
19
+
3
20
  ## 0.9.52 - beta
4
21
 
5
22
  - Actionable setup audit. Every finding of `setup_audit.py` carries an `action`: the file and edit, the command to run
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.52 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
20
+ **Status:** 0.9.53 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
21
21
 
22
22
  ## How it works
23
23
 
@@ -83,11 +83,13 @@ gateway such as Ollama, nothing about your code leaves the machine.
83
83
  ## Install
84
84
 
85
85
  ```powershell
86
- npx @allansantos-dev/smart-tool@0.9.52 install
86
+ npx @allansantos-dev/smart-tool@0.9.53 install
87
87
  ```
88
88
 
89
89
  Updates install themselves, on by default: the tray checks npm when it starts (at logon) and every 24 h, and when there
90
- is a newer version it runs this command with that version in place of the one above, behind its own small update
90
+ is a newer version it runs this command with that version in place of the one above and `--yes --prefer-online` before
91
+ the package name (npm asks the registry instead of its cached version list, which misses a release published minutes
92
+ ago), behind its own small update
91
93
  window, with no console window (once per
92
94
  version; a failed version is tried again after 24 h, with the previous version kept). The window has no buttons: it shows
93
95
  the version change, the current step and the result, and closes by itself; the command's output is kept in
@@ -98,7 +100,8 @@ X" (or "Check for updates") on demand and an "Update automatically" switch; `SMA
98
100
  automatic updates off, and the newer-version notice then carries the command to run. The interface (tray, notifications,
99
101
  settings and projects pages, update window) is in Brazilian Portuguese or English: it follows the Windows display
100
102
  language until you pick one with the globe button (PT/EN) at the top of the pages or the tray's "Idioma / Language"
101
- submenu. Running the command by hand with a newer version also updates; `~/.smart-tool` is kept. It downloads [uv](https://docs.astral.sh/uv/) (checksum
103
+ submenu. Running the command by hand with a newer version also updates (add `--prefer-online` before the package name when that
104
+ version came out minutes ago); `~/.smart-tool` is kept. It downloads [uv](https://docs.astral.sh/uv/) (checksum
102
105
  verified) and a private Python 3.12 into `~/.smart-tool/runtime`, with nothing added to `PATH` and, in the registry, only two per-user (HKCU) keys that make the notification buttons work, then
103
106
  copies Smart Tool to `%LOCALAPPDATA%\Programs\SmartTool` with its own virtual environment,
104
107
  installs the web runtime, registers a per-user Scheduled Task that starts the tray at logon and starts the daemon on
@@ -19,7 +19,8 @@ const PYTHON_DIR = join(RUNTIME_DIR, "python");
19
19
  const USAGE = `Usage: npx @allansantos-dev/smart-tool@<version> install [--target DIR] [--no-start] [--skip-deps]
20
20
 
21
21
  Installs or updates Smart Tool for this Windows user. To update, run it again with the version to install in place of
22
- <version>: a pinned version keeps npx from reusing an older package from its cache.`;
22
+ <version>: a pinned version keeps npx from reusing an older package from its cache. For a version published minutes
23
+ ago, add --prefer-online before the package name so npm asks the registry instead of its cached version list.`;
23
24
 
24
25
  function fail(message) {
25
26
  throw new Failure(message);
package/notice_action.py CHANGED
@@ -11,11 +11,13 @@ import urllib.parse
11
11
  import webbrowser
12
12
 
13
13
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
14
+ import atomic_io
14
15
  import model_upgrade
15
16
  import paths
16
17
  import toast_notice
17
18
 
18
19
  LOG_PATH = os.path.join(paths.DATA_DIR, "notice-actions.log")
20
+ LOG_MAX_BYTES = 256 * 1024
19
21
 
20
22
 
21
23
  def run(uri):
@@ -48,7 +50,9 @@ def run(uri):
48
50
 
49
51
 
50
52
  def main(argv):
51
- """Runs the link in `argv[1]` and logs the outcome; returns the process exit code (0 done, 1 refused)."""
53
+ """Runs the link in `argv[1]` and logs the outcome; returns the process exit code (0 done, 1 refused). The link
54
+ comes from whatever opened the protocol, so its line breaks are joined: one entry is one line. The log keeps one
55
+ previous generation (`notice-actions.log.1`) past LOG_MAX_BYTES."""
52
56
  os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
53
57
  stamp = time.strftime("%Y-%m-%d %H:%M:%S")
54
58
  try:
@@ -57,8 +61,9 @@ def main(argv):
57
61
  except Exception as exc:
58
62
  line = f"{stamp} FAIL {argv[1] if len(argv) > 1 else ''} -> {type(exc).__name__}: {exc}"
59
63
  code = 1
64
+ atomic_io.rotate(LOG_PATH, LOG_MAX_BYTES)
60
65
  with open(LOG_PATH, "a", encoding="utf-8") as log:
61
- log.write(line + "\n")
66
+ log.write(" ".join(line.split()) + "\n")
62
67
  return code
63
68
 
64
69
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allansantos-dev/smart-tool",
3
- "version": "0.9.52",
3
+ "version": "0.9.53",
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
@@ -20,6 +20,7 @@ from PIL import Image, ImageDraw
20
20
  import pystray
21
21
 
22
22
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
23
+ import atomic_io
23
24
  import autostart
24
25
  import config
25
26
  import daemon_launcher
@@ -37,6 +38,7 @@ NOTICE_RETRY_S = 15
37
38
  UPDATE_RETRY_S = 300
38
39
  NOTICE_UNREACHABLE_LOG_S = 600
39
40
  LOG_PATH = os.path.join(paths.DATA_DIR, "tray.log")
41
+ LOG_MAX_BYTES = 256 * 1024
40
42
  SETUP_URL = "http://127.0.0.1:8765/setup"
41
43
 
42
44
  _STATE_LOCK = threading.Lock()
@@ -181,11 +183,13 @@ def _show_notices(icon, notices):
181
183
 
182
184
  def _log(text):
183
185
  """Appends a line to `tray.log` in the data folder: what the tray cannot tell with a notification (a notice that could
184
- not be fetched or shown) is kept where the user can read it, never turned into another notification."""
186
+ not be fetched or shown) is kept where the user can read it, never turned into another notification. One line per
187
+ entry (an exception text with line breaks is joined) and one previous generation (`tray.log.1`) past LOG_MAX_BYTES."""
185
188
  try:
186
189
  os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
190
+ atomic_io.rotate(LOG_PATH, LOG_MAX_BYTES)
187
191
  with open(LOG_PATH, "a", encoding="utf-8") as log:
188
- log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} {text}\n")
192
+ log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} {' '.join(str(text).split())}\n")
189
193
  except OSError:
190
194
  pass # no console and no other channel here; a full disk must not kill the notice thread
191
195
 
package/update_check.py CHANGED
@@ -43,8 +43,9 @@ def newer_version(timeout=10):
43
43
 
44
44
  def update_command(target):
45
45
  """The npx command that installs version target, as told to the user and to agent sessions. Pinned rather than
46
- `@latest`, which lets npx reuse an older package from its cache."""
47
- return f"npx --yes {PACKAGE}@{target} install"
46
+ `@latest`, which lets npx reuse an older package from its cache; --prefer-online because npm's cached version list
47
+ does not have a release published minutes ago and fails with ETARGET."""
48
+ return f"npx --yes --prefer-online {PACKAGE}@{target} install"
48
49
 
49
50
 
50
51
  def env_opted_out():
package/update_splash.py CHANGED
@@ -51,12 +51,14 @@ def step_for(line):
51
51
 
52
52
  def install_command(target):
53
53
  """argv of the update: the npx command a user types, through cmd.exe because npx is a .cmd script, for the version
54
- the tray announced. `@latest` would let npx reuse an older package from its cache and install that instead, and
55
- --expect-version makes the installer refuse a package that is not that version."""
54
+ the tray announced. `@latest` would let npx reuse an older package from its cache and install that instead;
55
+ --prefer-online makes npm ask the registry for the package's version list, which in the first minutes after a
56
+ publication its cache does not yet have (ETARGET); --expect-version makes the installer refuse a package that is
57
+ not that version."""
56
58
  npx = node_locator.which("npx.cmd")
57
59
  if not npx:
58
60
  raise RuntimeError(i18n.t("Node.js (npx) was not found; install Node.js and try again."))
59
- return ["cmd.exe", "/d", "/c", npx, "--yes", f"{update_check.PACKAGE}@{target}", "install",
61
+ return ["cmd.exe", "/d", "/c", npx, "--yes", "--prefer-online", f"{update_check.PACKAGE}@{target}", "install",
60
62
  "--expect-version", target], npx
61
63
 
62
64
 
@@ -99,6 +101,15 @@ def run_install(lines, target):
99
101
  return code, last
100
102
 
101
103
 
104
+ def log_line(text):
105
+ """Appends text as one line to update_check.UPDATE_LOG: what the window shows only until it closes stays there."""
106
+ try:
107
+ with open(update_check.UPDATE_LOG, "a", encoding="utf-8") as log:
108
+ log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} {' '.join(str(text).split())}\n")
109
+ except OSError:
110
+ pass # the window note already shows it; a log that cannot be written must not hide the outcome
111
+
112
+
102
113
  def _single_instance():
103
114
  """True when no other update screen is running (a named mutex held for the life of this process)."""
104
115
  if sys.platform != "win32":
@@ -212,6 +223,7 @@ def main(argv):
212
223
  [(i18n.t("View log"), toast_notice.action_uri("open-update-log"))], tag="update-failed")
213
224
  except Exception as exc:
214
225
  splash.note.config(text=f"{splash.note.cget('text')}\n{exc}")
226
+ log_line(f"Windows notification not shown: {type(exc).__name__}: {exc}")
215
227
 
216
228
  splash.root.after(200, pump)
217
229
  splash.root.mainloop()
package/version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Single source of the Smart Tool version and of the User-Agent sent to public APIs."""
2
2
  import re
3
3
 
4
- VERSION = "0.9.52"
4
+ VERSION = "0.9.53"
5
5
  _CONTACT_RE = re.compile(r"^(?:[^\s@()<>;]+@[^\s@()<>;]+\.[^\s@()<>;]+|https?://[^\s()<>;]+)$")
6
6
 
7
7