@allansantos-dev/smart-tool 0.9.71 → 0.9.72

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.72 - beta
4
+
5
+ - A Smart Tool hook entry that is absent from the client's config is no longer reported `missing` when the Skill Manager holds
6
+ an item of Smart Tool back: `client_hooks.inspect` asks `skill-engine query --owner smart-tool --json` (through the `cli.json`
7
+ pointer in `SKILL_ENGINE_HOME` or `~/.skill-engine`) and answers `waiting_approval` for a quarantined or held item and
8
+ `update_held` for an approved copy whose new version waits; the settings page shows "Waiting for approval" and "Update held",
9
+ and the notice to the agent says there is nothing to install. Without the Manager, or with items active or absent, the
10
+ state stays `missing`; a failed query shows as the hook being unreadable. Tests: `tests/test_hook_manager_state.py`.
11
+
3
12
  ## 0.9.71 - beta
4
13
 
5
14
  - `npx @allansantos-dev/smart-tool@0.9.71 uninstall [--target DIR] [--keep-data]` (`python uninstall.py`): silent uninstall that
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.71 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
20
+ **Status:** 0.9.72 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
21
21
 
22
22
  ## How it works
23
23
 
@@ -83,7 +83,7 @@ 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.71 install
86
+ npx @allansantos-dev/smart-tool@0.9.72 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
@@ -382,7 +382,7 @@ fails to load is listed in the setup screen with its error and does not affect t
382
382
  ## Uninstall
383
383
 
384
384
  ```powershell
385
- npx @allansantos-dev/smart-tool@0.9.71 uninstall [--target DIR] [--keep-data]
385
+ npx @allansantos-dev/smart-tool@0.9.72 uninstall [--target DIR] [--keep-data]
386
386
  ```
387
387
 
388
388
  It asks nothing and opens no window. It stops the tray and the daemon, removes the logon task, the hook entries of Smart
package/client_hooks.py CHANGED
@@ -3,6 +3,7 @@ import json
3
3
  import os
4
4
  import secrets
5
5
  import shutil
6
+ import subprocess
6
7
  import sys
7
8
  import time
8
9
  import tomllib
@@ -23,6 +24,9 @@ AUDIT_TIMEOUT_S = 10
23
24
  AUDIT_CLIENTS = ("claude", "codex")
24
25
  AUDIT_ON = "current"
25
26
  AUDIT_WAITING = "waiting_approval"
27
+ OWNER = "smart-tool"
28
+ MANAGER_TIMEOUT_S = 5
29
+ MANAGER_HELD = ("quarantined", "held")
26
30
  HTTP_PATH = "/hooks/pretool"
27
31
  POST_PATH = "/hooks/posttool"
28
32
  # A redirected shell search waits for its answer in the PreToolUse (smart_tool_daemon.HOOK_SHELL_BUDGET_S).
@@ -89,10 +93,47 @@ def _target(handler):
89
93
  return handler.get("url") or handler.get("command") or ""
90
94
 
91
95
 
92
- def inspect(client, trust=True):
96
+ def manager_items(owner=OWNER):
97
+ """Items the Skill Manager holds for `owner` (`skill-engine query --owner <owner> --json`), found through the
98
+ cli.json pointer in its home (SKILL_ENGINE_HOME or ~/.skill-engine). [] when the Manager is not installed;
99
+ an unreadable pointer or a failed query raises."""
100
+ pointer = os.path.join(os.environ.get("SKILL_ENGINE_HOME") or os.path.join(HOME, ".skill-engine"), "cli.json")
101
+ try:
102
+ with open(pointer, encoding="utf-8") as stream:
103
+ cli = json.load(stream)
104
+ except FileNotFoundError:
105
+ return []
106
+ flags = subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0
107
+ result = subprocess.run([cli["node"], cli["cli"], "query", "--owner", owner, "--json"], capture_output=True,
108
+ stdin=subprocess.DEVNULL, text=True, encoding="utf-8", errors="replace",
109
+ timeout=MANAGER_TIMEOUT_S, creationflags=flags)
110
+ if result.returncode != 0:
111
+ raise OSError(f"skill-engine query exited {result.returncode}: {result.stderr.strip()[:200]}")
112
+ return json.loads(result.stdout).get("items") or []
113
+
114
+
115
+ def _missing_state():
116
+ """`missing`, unless the Skill Manager holds something of ours back: `waiting_approval` for a quarantined or held
117
+ item, `update_held` for an approved copy whose new version waits."""
118
+ items = manager_items()
119
+ waiting = [item for item in items if item.get("state") in MANAGER_HELD]
120
+ if waiting:
121
+ return {"state": "waiting_approval", "changes": [f"{item.get('id')}: {item.get('reason') or item['state']}. "
122
+ f"Approve with `{item.get('approve') or 'skill-engine dashboard'}`."
123
+ for item in waiting]}
124
+ pending = [item for item in items if item.get("pendingUpdate")]
125
+ if pending:
126
+ return {"state": "update_held", "changes": [f"{item.get('id')}: a new version waits for approval "
127
+ f"(`{item.get('approve') or 'skill-engine dashboard'}`)." for item in pending]}
128
+ return {"state": "missing", "changes": []}
129
+
130
+
131
+ def inspect(client, trust=True, manager=True):
93
132
  """Our hook in the client's config: `current`, `missing`, or `outdated` (an older entry of ours) with `changes`,
94
133
  plain sentences saying what an update rewrites (tools the old matcher leaves out, an old address or timeout).
95
- In Codex a current entry that config.toml does not trust is outdated too, unless trust=False."""
134
+ In Codex a current entry that config.toml does not trust is outdated too, unless trust=False. Where the entry is
135
+ absent and the Skill Manager holds an item of ours, `waiting_approval` or `update_held` (manager=False skips that
136
+ query)."""
96
137
  spec = CLIENTS[client]
97
138
  for path in spec["files"]:
98
139
  try:
@@ -113,7 +154,7 @@ def inspect(client, trust=True):
113
154
  if client == "codex" and trust and not changes and not _codex_trusted(event, groups, _our_hook):
114
155
  changes.append(f"Codex has not approved its {event} entry; an update records the approval.")
115
156
  return {"state": "outdated" if changes else "current", "changes": changes}
116
- return {"state": "missing", "changes": []}
157
+ return _missing_state() if manager else {"state": "missing", "changes": []}
117
158
 
118
159
 
119
160
  def _entry_changes(event, matcher, expected, groups):
@@ -153,7 +194,7 @@ def status(client_info):
153
194
  spec = CLIENTS[client]
154
195
  try:
155
196
  found, error = inspect(client), None
156
- except (OSError, ValueError) as exc:
197
+ except (OSError, ValueError, subprocess.SubprocessError) as exc:
157
198
  found, error = {"state": None, "changes": []}, f"{type(exc).__name__}: {exc}"[:200]
158
199
  return {"client": client, "name": client_info.get("name"),
159
200
  "installed": None if found["state"] is None else found["state"] == "current", "state": found["state"],
@@ -172,6 +213,10 @@ def notice(state):
172
213
  return None
173
214
  action = spec.get("blocked") or ("If the user asks, use project_manage action=install_hook_preview, show the "
174
215
  "change and confirm with action=install_hook (makes a backup).")
216
+ if state.get("state") in ("waiting_approval", "update_held"):
217
+ label = "waiting for approval" if state["state"] == "waiting_approval" else "update held"
218
+ return (f"Smart Tool hook {label} in the Skill Manager ({spec['label']}): {' '.join(state['changes'])} "
219
+ "Nothing to install.")
175
220
  if state.get("state") == "outdated":
176
221
  return (f"Smart Tool hook outdated in {spec['label']} ({spec['files'][0]}): {' '.join(state['changes'])} "
177
222
  f"{action} Docs: {spec['docs']}")
@@ -311,7 +356,7 @@ def remove(client):
311
356
  del hooks[event]
312
357
  if not moved:
313
358
  return {"client": client, "changed": False, "file": path, "backup": None}
314
- backup = _write_checked(path, data, lambda: inspect(client, trust=False)["state"] == "missing", "The removal")
359
+ backup = _write_checked(path, data, lambda: inspect(client, trust=False, manager=False)["state"] == "missing", "The removal")
315
360
  if client == "codex":
316
361
  for event, (before, kept) in moved.items():
317
362
  record_codex_trust(_codex_trust(event, before, kept))
@@ -113,6 +113,16 @@
113
113
  "The redirect hook was written by an older Smart Tool.": "O hook de redirecionamento foi gravado por uma versão mais antiga do Smart Tool.",
114
114
  "No hook": "Sem hook",
115
115
  "Install hook": "Instalar hook",
116
+ "Waiting for approval": "Aguardando aprovação",
117
+ "The Skill Manager holds a Smart Tool item until you approve it.": "O Skill Manager retém um item do Smart Tool até você aprovar.",
118
+ "Update held": "Atualização retida",
119
+ "A new Smart Tool version waits for approval in the Skill Manager.": "Uma nova versão do Smart Tool aguarda aprovação no Skill Manager.",
120
+ "Smart Tool hook {0} in the Skill Manager ({1}): {2} Nothing to install.": "Hook do Smart Tool {0} no Skill Manager ({1}): {2} Não há nada a instalar.",
121
+ "waiting for approval": "aguardando aprovação",
122
+ "update held": "atualização retida",
123
+ "{0}: {1}. Approve with `{2}`.": "{0}: {1}. Aprove com `{2}`.",
124
+ "{0}: a new version waits for approval (`{1}`).": "{0}: uma nova versão aguarda aprovação (`{1}`).",
125
+ "skill-engine dashboard": "skill-engine dashboard",
116
126
  "Connected, but its folder searches and web lookups are not redirected to Smart Tool.": "Conectado, mas as buscas em pastas e as consultas na web dele não são redirecionadas para o Smart Tool.",
117
127
  "Connected": "Conectado",
118
128
  "Connection and redirect hook are up to date.": "A conexão e o hook de redirecionamento estão atualizados.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allansantos-dev/smart-tool",
3
- "version": "0.9.71",
3
+ "version": "0.9.72",
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": "Smart Tool contributors",
package/setup_ui.py CHANGED
@@ -945,6 +945,10 @@ function agentState(item) {
945
945
  text: "Could not read " + item.file + ": " + item.hook_error };
946
946
  if (item.hook_state === "outdated") return { tone: "warn", label: "Hook outdated", action: "Update hook", hook: true,
947
947
  text: "The redirect hook was written by an older Smart Tool. " + item.hook_changes.join(" ") };
948
+ if (item.hook_state === "waiting_approval") return { tone: "warn", label: "Waiting for approval", action: "Open",
949
+ text: "The Skill Manager holds a Smart Tool item until you approve it. " + item.hook_changes.join(" ") };
950
+ if (item.hook_state === "update_held") return { tone: "warn", label: "Update held", action: "Open",
951
+ text: "A new Smart Tool version waits for approval in the Skill Manager. " + item.hook_changes.join(" ") };
948
952
  if (item.hook_state === "missing") return { tone: "warn", label: "No hook", action: "Install hook", hook: true,
949
953
  text: "Connected, but its folder searches and web lookups are not redirected to Smart Tool." };
950
954
  return { tone: "ok", label: "Connected", action: "Open", text: "Connection and redirect hook are up to date." };
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.71"
4
+ VERSION = "0.9.72"
5
5
  _CONTACT_RE = re.compile(r"^(?:[^\s@()<>;]+@[^\s@()<>;]+\.[^\s@()<>;]+|https?://[^\s()<>;]+)$")
6
6
 
7
7