@allansantos-dev/smart-tool 0.9.24 → 0.9.25

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.25 - beta
4
+
5
+ - A redirected search made while the first index of a folder is still being built no longer waits in the folder's queue
6
+ behind the build (22 s measured, past the hook's 15 s, so the agent got the native result with no notice): it is
7
+ answered at once by the keyword search of the disk, with the redirect notice and the index-loading warning.
8
+ - The first search of a cold folder also gets the index-loading sentence in the notice (it was read from a job field that
9
+ the answer text does not carry; it is now read from the answer's own warning).
10
+
3
11
  ## 0.9.24 - beta
4
12
 
5
13
  - A redirected search now tells the agent what happened: the answer opens with a line saying the search was redirected to
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.24 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
18
+ **Status:** 0.9.25 beta. Windows only. What changed in each version: [CHANGELOG.md](CHANGELOG.md).
19
19
 
20
20
  ## How it works
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allansantos-dev/smart-tool",
3
- "version": "0.9.24",
3
+ "version": "0.9.25",
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",
@@ -3654,6 +3654,18 @@ def _decide_within_budget(payload, client):
3654
3654
  return output
3655
3655
 
3656
3656
 
3657
+ def _cold_index_building(root):
3658
+ """Whether the folder has no index yet and the job that builds it is queued or running. A search job of that folder
3659
+ would wait behind it in the per-folder queue (21.9 s measured, past the hook's wait), so a redirected search is
3660
+ answered at once by `_perform_smart_search`'s cold path: keyword matches read from disk, with the notice."""
3661
+ if indexer.info(root).get("chunks") or not _cold_index(root, config.load_config(), _gateway_problem()):
3662
+ return False
3663
+ project_id = project_identity.project_id(root)
3664
+ with _JOBS_LOCK:
3665
+ return any(job.get("kind") == "project_index" and job.get("status") == "pending"
3666
+ and job.get("project_id") == project_id for job in _jobs.values())
3667
+
3668
+
3657
3669
  def _redirected_search(arguments):
3658
3670
  """smart_search text for a redirected native search, waiting up to SMART_SEARCH_SYNC_WAIT_S; raises when the search
3659
3671
  is rejected, fails or is still running then. The hook's single_language_reason only passes the language check, it is
@@ -3661,6 +3673,8 @@ def _redirected_search(arguments):
3661
3673
  redirected, whether the index is still loading, and to keep using smart_search."""
3662
3674
  checked = _smart_search_arguments(arguments)
3663
3675
  checked.pop("single_language_reason", None)
3676
+ if _cold_index_building(checked["project_root"]):
3677
+ return f"{tool_redirect.search_notice(True)}\n{_perform_smart_search(checked, '')}"
3664
3678
  job_id, _future = _submit_project_job("smart_search", checked)
3665
3679
  deadline = time.monotonic() + SMART_SEARCH_SYNC_WAIT_S
3666
3680
  payload = _smart_search_job_payload(job_id)
@@ -3669,8 +3683,8 @@ def _redirected_search(arguments):
3669
3683
  payload = _smart_search_job_payload(job_id)
3670
3684
  if payload["status"] != "done":
3671
3685
  raise RuntimeError(f"smart_search job {job_id} is {payload['status']}: {payload.get('error') or ''}"[:300])
3672
- indexing = str(payload.get("warning") or "").startswith("Indexing in progress")
3673
- return f"{tool_redirect.search_notice(indexing)}\n{_agent_search_answer(payload)}"
3686
+ answer = _agent_search_answer(payload)
3687
+ return f"{tool_redirect.search_notice('Indexing in progress' in answer.partition(chr(10) + 'code:')[0])}\n{answer}"
3674
3688
 
3675
3689
 
3676
3690
  def _redirected_text(handler):
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.24"
4
+ VERSION = "0.9.25"
5
5
  _CONTACT_RE = re.compile(r"^(?:[^\s@()<>;]+@[^\s@()<>;]+\.[^\s@()<>;]+|https?://[^\s()<>;]+)$")
6
6
 
7
7