@hasna/search 0.0.7 → 0.0.9

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 (59) hide show
  1. package/README.md +68 -7
  2. package/dist/cli/index.js +10483 -12908
  3. package/dist/cli/local.d.ts +3 -0
  4. package/dist/cli/local.d.ts.map +1 -0
  5. package/dist/cli/storage.d.ts +3 -0
  6. package/dist/cli/storage.d.ts.map +1 -0
  7. package/dist/db/database.d.ts +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-migrate.d.ts +8 -0
  15. package/dist/db/pg-migrate.d.ts.map +1 -0
  16. package/dist/db/pg-migrations.d.ts +1 -1
  17. package/dist/db/providers.d.ts.map +1 -1
  18. package/dist/db/remote-storage.d.ts +12 -0
  19. package/dist/db/remote-storage.d.ts.map +1 -0
  20. package/dist/db/storage-config.d.ts +26 -0
  21. package/dist/db/storage-config.d.ts.map +1 -0
  22. package/dist/db/storage-sync.d.ts +35 -0
  23. package/dist/db/storage-sync.d.ts.map +1 -0
  24. package/dist/index.d.ts +11 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +6850 -8733
  27. package/dist/lib/config.d.ts.map +1 -1
  28. package/dist/lib/dedup.d.ts.map +1 -1
  29. package/dist/lib/local/find.d.ts +38 -0
  30. package/dist/lib/local/find.d.ts.map +1 -0
  31. package/dist/lib/local/ignore.d.ts +38 -0
  32. package/dist/lib/local/ignore.d.ts.map +1 -0
  33. package/dist/lib/local/indexer.d.ts +57 -0
  34. package/dist/lib/local/indexer.d.ts.map +1 -0
  35. package/dist/lib/local/query.d.ts +60 -0
  36. package/dist/lib/local/query.d.ts.map +1 -0
  37. package/dist/lib/local/regex.d.ts +26 -0
  38. package/dist/lib/local/regex.d.ts.map +1 -0
  39. package/dist/lib/local/walker.d.ts +30 -0
  40. package/dist/lib/local/walker.d.ts.map +1 -0
  41. package/dist/lib/providers/content.d.ts +9 -0
  42. package/dist/lib/providers/content.d.ts.map +1 -0
  43. package/dist/lib/providers/files.d.ts +9 -0
  44. package/dist/lib/providers/files.d.ts.map +1 -0
  45. package/dist/lib/providers/index.d.ts.map +1 -1
  46. package/dist/lib/search.d.ts.map +1 -1
  47. package/dist/mcp/index.js +7520 -10144
  48. package/dist/mcp/server.d.ts +1 -1
  49. package/dist/mcp/server.d.ts.map +1 -1
  50. package/dist/mcp/storage-tools.d.ts +3 -0
  51. package/dist/mcp/storage-tools.d.ts.map +1 -0
  52. package/dist/server/index.js +13965 -16510
  53. package/dist/server/serve.d.ts.map +1 -1
  54. package/dist/storage.d.ts +7 -0
  55. package/dist/storage.d.ts.map +1 -0
  56. package/dist/storage.js +5584 -0
  57. package/dist/types/index.d.ts +10 -2
  58. package/dist/types/index.d.ts.map +1 -1
  59. package/package.json +18 -5
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,9 @@ 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.
27
83
 
28
84
  ## HTTP mode
29
85
 
@@ -42,16 +98,21 @@ MCP_HTTP=1 search-mcp
42
98
  search-serve
43
99
  ```
44
100
 
45
- ## Cloud Sync
101
+ `/api/find`, `/api/index`, `/api/search`, and the dashboard (with a Local tab) on port 19800.
46
102
 
47
- This package supports cloud sync via `@hasna/cloud`:
103
+ ## Storage Sync
104
+
105
+ Storage sync is optional. By default search uses local SQLite at `~/.hasna/search/`.
48
106
 
49
107
  ```bash
50
- cloud setup
51
- cloud sync push --service search
52
- cloud sync pull --service search
108
+ search storage status
109
+ search storage push
110
+ search storage pull
111
+ search storage sync
53
112
  ```
54
113
 
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`.
115
+
55
116
  ## Data Directory
56
117
 
57
118
  Data is stored in `~/.hasna/search/`.