@hasna/search 0.0.8 → 0.0.10

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.
Files changed (65) hide show
  1. package/LICENSE +2 -1
  2. package/README.md +78 -9
  3. package/dist/cli/index.js +1761 -198
  4. package/dist/cli/local.d.ts +3 -0
  5. package/dist/cli/local.d.ts.map +1 -0
  6. package/dist/cli/storage.d.ts +3 -0
  7. package/dist/cli/storage.d.ts.map +1 -0
  8. package/dist/db/database.d.ts.map +1 -1
  9. package/dist/db/index-db.d.ts +6 -0
  10. package/dist/db/index-db.d.ts.map +1 -0
  11. package/dist/db/index-migrations.d.ts +3 -0
  12. package/dist/db/index-migrations.d.ts.map +1 -0
  13. package/dist/db/migrations.d.ts.map +1 -1
  14. package/dist/db/pg-migrations.d.ts +1 -1
  15. package/dist/db/providers.d.ts.map +1 -1
  16. package/dist/db/storage-config.d.ts +26 -0
  17. package/dist/db/storage-config.d.ts.map +1 -0
  18. package/dist/db/storage-sync.d.ts +35 -0
  19. package/dist/db/storage-sync.d.ts.map +1 -0
  20. package/dist/index.d.ts +9 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2459 -118
  23. package/dist/lib/config.d.ts.map +1 -1
  24. package/dist/lib/dedup.d.ts.map +1 -1
  25. package/dist/lib/local/find.d.ts +38 -0
  26. package/dist/lib/local/find.d.ts.map +1 -0
  27. package/dist/lib/local/ignore.d.ts +38 -0
  28. package/dist/lib/local/ignore.d.ts.map +1 -0
  29. package/dist/lib/local/indexer.d.ts +62 -0
  30. package/dist/lib/local/indexer.d.ts.map +1 -0
  31. package/dist/lib/local/query.d.ts +60 -0
  32. package/dist/lib/local/query.d.ts.map +1 -0
  33. package/dist/lib/local/regex.d.ts +26 -0
  34. package/dist/lib/local/regex.d.ts.map +1 -0
  35. package/dist/lib/local/walker.d.ts +30 -0
  36. package/dist/lib/local/walker.d.ts.map +1 -0
  37. package/dist/lib/providers/content.d.ts +9 -0
  38. package/dist/lib/providers/content.d.ts.map +1 -0
  39. package/dist/lib/providers/files.d.ts +9 -0
  40. package/dist/lib/providers/files.d.ts.map +1 -0
  41. package/dist/lib/providers/index.d.ts.map +1 -1
  42. package/dist/lib/search.d.ts.map +1 -1
  43. package/dist/mcp/http.d.ts +15 -0
  44. package/dist/mcp/http.d.ts.map +1 -0
  45. package/dist/mcp/index.js +14334 -11630
  46. package/dist/mcp/server.d.ts +5 -0
  47. package/dist/mcp/server.d.ts.map +1 -0
  48. package/dist/mcp/storage-tools.d.ts +3 -0
  49. package/dist/mcp/storage-tools.d.ts.map +1 -0
  50. package/dist/server/index.js +28445 -4917
  51. package/dist/server/serve.d.ts.map +1 -1
  52. package/dist/storage.d.ts +7 -0
  53. package/dist/storage.d.ts.map +1 -0
  54. package/dist/storage.js +5584 -0
  55. package/dist/types/index.d.ts +10 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/package.json +16 -4
  58. package/dist/cli/cloud.d.ts +0 -3
  59. package/dist/cli/cloud.d.ts.map +0 -1
  60. package/dist/db/cloud-config.d.ts +0 -14
  61. package/dist/db/cloud-config.d.ts.map +0 -1
  62. package/dist/db/cloud-sync.d.ts +0 -30
  63. package/dist/db/cloud-sync.d.ts.map +0 -1
  64. package/dist/mcp/cloud-tools.d.ts +0 -3
  65. package/dist/mcp/cloud-tools.d.ts.map +0 -1
package/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -175,7 +176,7 @@
175
176
 
176
177
  END OF TERMS AND CONDITIONS
177
178
 
178
- Copyright 2025 Andrei Hasna
179
+ Copyright 2026 Hasna, Inc.
179
180
 
180
181
  Licensed under the Apache License, Version 2.0 (the "License");
181
182
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @hasna/search
2
2
 
3
- Unified search aggregator — 12 providers (Google, SerpAPI, Exa, Perplexity, Twitter, Reddit, YouTube, Brave, Bing, Hacker News, GitHub, arXiv) + YouTube transcription. CLI + MCP + REST API + Dashboard.
3
+ Unified search for machines and agents a **local file index** (find files by name, path, or content in milliseconds) plus **12 web providers** (Google, SerpAPI, Exa, Perplexity, Twitter, Reddit, YouTube, Brave, Bing, Hacker News, GitHub, arXiv) and YouTube transcription. CLI + MCP + REST API + Dashboard.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@hasna/search)](https://www.npmjs.com/package/@hasna/search)
6
6
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
@@ -11,6 +11,60 @@ Unified search aggregator — 12 providers (Google, SerpAPI, Exa, Perplexity, Tw
11
11
  npm install -g @hasna/search
12
12
  ```
13
13
 
14
+ ## Local Search
15
+
16
+ Index a workspace once, then find anything in one call:
17
+
18
+ ```bash
19
+ search index add ~/workspace # register + index (gitignore-aware, incremental)
20
+ search find storage-config # by file name/path
21
+ search find "deduplicate results" # by content, with line numbers
22
+ search find dedup -k file -e ts # filters: kind, extension, dir, root
23
+ search index status # roots, file counts, staleness
24
+ search index update # incremental reindex (auto-runs when stale)
25
+ ```
26
+
27
+ The index lives in SQLite (`~/.hasna/search/index.db`) using trigram FTS5 for substring
28
+ matching. Re-indexing only touches changed files; stale roots refresh automatically
29
+ before serving results. `node_modules`, `.git`, build output, binaries, and anything
30
+ in `.gitignore` are excluded.
31
+
32
+ Local results also join unified search as the `files` and `content` providers
33
+ (`search query dedup --profile local`, or blended with web providers via `--profile all`).
34
+
35
+ Regex (grep-style) search works too, Cursor-style — required literals from the
36
+ pattern prefilter candidates through the trigram index, then the real regex runs
37
+ only on those files:
38
+
39
+ ```bash
40
+ search find "export (function|const) handle\w+" -x # regex, line-based
41
+ search find "storage-(config|sync)\.ts$" -x -k file # regex over paths
42
+ ```
43
+
44
+ ### Performance
45
+
46
+ Measured on a 158,140-file workspace index (79GB tree, 1.8GB index), warm cache,
47
+ 20-core Linux box — `search find -k content` vs `ripgrep -l`, wall clock per query:
48
+
49
+ | Query | ripgrep | search find |
50
+ |---|---|---|
51
+ | `contentless_delete` | 0.65s | 0.06s |
52
+ | `registerStorageCommands` | 0.20s | 0.07s |
53
+ | `IgnoreMatcher` | 0.20s | 0.06s |
54
+
55
+ CPU per query: rg ~2.2s across cores; find ~0.08s on one. Initial indexing of the
56
+ same tree: 166s; incremental re-index when nothing changed: ~2.7s (runs
57
+ automatically at most once per `indexStaleMinutes`). Results come back ranked,
58
+ deduplicated across file-name and content matches, and scoped to all indexed
59
+ roots regardless of the caller's working directory.
60
+
61
+ ## Web Search
62
+
63
+ ```bash
64
+ search query "bun sqlite fts5" --profile research
65
+ search exa "semantic search" # any provider directly
66
+ ```
67
+
14
68
  ## CLI Usage
15
69
 
16
70
  ```bash
@@ -23,7 +77,20 @@ search --help
23
77
  search-mcp
24
78
  ```
25
79
 
26
- 31 tools available.
80
+ Agent-facing tools include `find` (one-call local file lookup), `index_add` /
81
+ `index_update` / `index_status` / `index_remove`, unified `search`, per-provider
82
+ `search_*` tools, history, saved searches, profiles, and export.
83
+
84
+ ## HTTP mode
85
+
86
+ ```bash
87
+ search-mcp --http # default port 8832
88
+ MCP_HTTP=1 search-mcp
89
+ ```
90
+
91
+ - Health: `GET http://127.0.0.1:8832/health`
92
+ - MCP: `http://127.0.0.1:8832/mcp`
93
+ - Stdio remains default. `search-serve` also mounts `/health` and `/mcp`.
27
94
 
28
95
  ## REST API
29
96
 
@@ -31,18 +98,20 @@ search-mcp
31
98
  search-serve
32
99
  ```
33
100
 
34
- ## Cloud Sync
101
+ `/api/find`, `/api/index`, `/api/search`, and the dashboard (with a Local tab) on port 19800.
102
+
103
+ ## Storage Sync
35
104
 
36
- Cloud sync is optional. By default search uses local SQLite at `~/.hasna/search/`.
105
+ Storage sync is optional. By default search uses local SQLite at `~/.hasna/search/`.
37
106
 
38
107
  ```bash
39
- search cloud status
40
- search cloud push
41
- search cloud pull
42
- search cloud sync
108
+ search storage status
109
+ search storage push
110
+ search storage pull
111
+ search storage sync
43
112
  ```
44
113
 
45
- Set `HASNA_SEARCH_CLOUD_DATABASE_URL` or configure `~/.hasna/search/cloud/config.json` to run in hybrid/cloud mode with PostgreSQL.
114
+ Set `HASNA_SEARCH_DATABASE_URL` or `SEARCH_DATABASE_URL` to run in hybrid/remote mode with PostgreSQL. RDS host settings can be configured in `~/.hasna/search/storage/config.json`. Programmatic storage helpers are available from `@hasna/search/storage`.
46
115
 
47
116
  ## Data Directory
48
117