@allansantos-dev/smart-tool 0.9.23 → 0.9.24
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 +11 -0
- package/README.md +1 -1
- package/hook_decision.py +3 -3
- package/package.json +1 -1
- package/smart_tool_daemon.py +5 -3
- package/tool_redirect.py +9 -0
- package/version.py +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.24 - beta
|
|
4
|
+
|
|
5
|
+
- A redirected search now tells the agent what happened: the answer opens with a line saying the search was redirected to
|
|
6
|
+
`smart_search` (index, related code, dependency map), that the index of the project is still loading when the answer is
|
|
7
|
+
a keyword search of the disk (the next searches will have it ready), and to keep using `smart_search`. Before, the
|
|
8
|
+
answer carried no word of the redirect.
|
|
9
|
+
- The deny text of a search that cannot be redirected no longer says that reading or searching inside one known file is
|
|
10
|
+
never blocked: no message the agent receives offers a way around the redirect (file by file, narrower scope).
|
|
11
|
+
`NoWayAroundTheRedirectTest` fails if any of those texts (deny, advice, redirect notice, cold-index and stale-index
|
|
12
|
+
warnings) suggests one.
|
|
13
|
+
|
|
3
14
|
## 0.9.23 - beta
|
|
4
15
|
|
|
5
16
|
- The hook no longer blocks. A content search over a project folder (the Grep tool on a folder, `grep -r`, `rg`,
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ registered as the `playwright` server where this machine lets a browser be drive
|
|
|
15
15
|
An optional hook routes the agent's native Grep/Glob/Read/Bash/WebSearch/WebFetch calls to these tools when they
|
|
16
16
|
are cheaper, or just tells the agent what Smart Tool would do.
|
|
17
17
|
|
|
18
|
-
**Status:** 0.9.
|
|
18
|
+
**Status:** 0.9.24 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
|
|
19
19
|
|
|
20
20
|
## How it works
|
|
21
21
|
|
package/hook_decision.py
CHANGED
|
@@ -138,14 +138,14 @@ def _load_hint(client, tool):
|
|
|
138
138
|
|
|
139
139
|
def redirect_message(client, tool_name, target, reason, cwd):
|
|
140
140
|
"""Deny text for a broad raw search: the exact tool and arguments to call (project_root from the folder the search
|
|
141
|
-
reads), and that rewriting the same search in Bash, python, node or PowerShell is the bypass the rule stops.
|
|
141
|
+
reads), and that rewriting the same search in Bash, python, node or PowerShell is the bypass the rule stops. It
|
|
142
|
+
never suggests a way around the rule (narrower or per-file searches): the only way offered is smart_search."""
|
|
142
143
|
root = _search_root(target, cwd).replace("\\", "/")
|
|
143
144
|
return (f"Blocked by Smart Tool, a routing rule set by the user, not a failure ({tool_name}: {clean_reason(reason)}). "
|
|
144
145
|
f'Run this search with {_tool_name(client, "smart_search")}: project_root="{root}", query_identifiers = what '
|
|
145
146
|
f"you are looking for in identifier terms (plus query_comments when the project has two languages)."
|
|
146
147
|
f'{_load_hint(client, "smart_search")} Do not repeat the same search through Bash, python, node or '
|
|
147
|
-
f"PowerShell: that bypasses the rule.
|
|
148
|
-
f"blocked.")
|
|
148
|
+
f"PowerShell: that bypasses the rule.")
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
def web_message(client, tool_name, url, why):
|
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.24",
|
|
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/smart_tool_daemon.py
CHANGED
|
@@ -3656,8 +3656,9 @@ def _decide_within_budget(payload, client):
|
|
|
3656
3656
|
|
|
3657
3657
|
def _redirected_search(arguments):
|
|
3658
3658
|
"""smart_search text for a redirected native search, waiting up to SMART_SEARCH_SYNC_WAIT_S; raises when the search
|
|
3659
|
-
is rejected, fails or is still running then. The hook's single_language_reason only passes the language check
|
|
3660
|
-
|
|
3659
|
+
is rejected, fails or is still running then. The hook's single_language_reason only passes the language check, it is
|
|
3660
|
+
not repeated as a warning. The answer opens with `tool_redirect.search_notice`: the agent is told its search was
|
|
3661
|
+
redirected, whether the index is still loading, and to keep using smart_search."""
|
|
3661
3662
|
checked = _smart_search_arguments(arguments)
|
|
3662
3663
|
checked.pop("single_language_reason", None)
|
|
3663
3664
|
job_id, _future = _submit_project_job("smart_search", checked)
|
|
@@ -3668,7 +3669,8 @@ def _redirected_search(arguments):
|
|
|
3668
3669
|
payload = _smart_search_job_payload(job_id)
|
|
3669
3670
|
if payload["status"] != "done":
|
|
3670
3671
|
raise RuntimeError(f"smart_search job {job_id} is {payload['status']}: {payload.get('error') or ''}"[:300])
|
|
3671
|
-
|
|
3672
|
+
indexing = str(payload.get("warning") or "").startswith("Indexing in progress")
|
|
3673
|
+
return f"{tool_redirect.search_notice(indexing)}\n{_agent_search_answer(payload)}"
|
|
3672
3674
|
|
|
3673
3675
|
|
|
3674
3676
|
def _redirected_text(handler):
|
package/tool_redirect.py
CHANGED
|
@@ -60,6 +60,15 @@ class Jobs:
|
|
|
60
60
|
self._futures.pop(key, None)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
+
def search_notice(indexing):
|
|
64
|
+
"""First line of a redirected search's answer: the agent made a native search, Smart Tool answered it. While the
|
|
65
|
+
index loads the answer is a keyword search of the disk; either way the agent is told to keep using smart_search."""
|
|
66
|
+
state = ("The index of this project is still loading, so this answer is a keyword search of the files on disk; "
|
|
67
|
+
"the next searches will have the index ready. " if indexing else "")
|
|
68
|
+
return ("Smart Tool: your search was redirected to smart_search, which searches the project index and returns "
|
|
69
|
+
f"related code with its dependency map. {state}Keep using smart_search for searches of the project.")
|
|
70
|
+
|
|
71
|
+
|
|
63
72
|
def output_for(tool_name, response, text):
|
|
64
73
|
"""`updatedToolOutput` for a native tool: its own response with the Smart Tool text in the field the model reads,
|
|
65
74
|
or None when the response has an unknown shape."""
|
package/version.py
CHANGED