@wenaixi/searchfuse 0.0.0-stage → 0.1.0

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 (52) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/LICENSE +21 -0
  3. package/README.md +169 -2
  4. package/README.zh-CN.md +170 -0
  5. package/SECURITY.md +20 -0
  6. package/claude/.claude-plugin/plugin.json +17 -0
  7. package/claude/SKILL.md +53 -0
  8. package/claude/hooks/hooks.json +3 -0
  9. package/claude/hooks/register.ts +552 -0
  10. package/cordis.patch.yml +16 -0
  11. package/dist/config-schema.js +40 -0
  12. package/dist/errorCause-BY0A0XKN.js +17 -0
  13. package/dist/kernel.js +62 -0
  14. package/dist/main.js +1371 -0
  15. package/dist/mcp-protocol.js +1 -0
  16. package/dist/mcp-registry.js +155 -0
  17. package/dist/protocol-ClnjMnGV.js +259 -0
  18. package/dist/proxy-DodOSGiI.js +50 -0
  19. package/dist/search-BIW13Csk.js +4061 -0
  20. package/dist/serve-Bfqz-nCB.js +279 -0
  21. package/dist/serve-ensure.js +140 -0
  22. package/docs/commit.md +77 -0
  23. package/docs/dsh.md +205 -0
  24. package/docs/harness-setup.md +78 -0
  25. package/docs/parity-matrix.md +61 -0
  26. package/docs/searxng-setup.md +117 -0
  27. package/docs/security.md +59 -0
  28. package/docs/settings-redesign-decisions.md +407 -0
  29. package/docs/superpowers/plans/2026-11-24-serve-lifecycle.md +880 -0
  30. package/docs/superpowers/reports/2026-11-24-serve-lifecycle-ledger.md +211 -0
  31. package/docs/superpowers/specs/2026-11-20-searchfuse-dual-host-design.md +172 -0
  32. package/docs/superpowers/specs/2026-11-21-searchfuse-tri-host-design.md +659 -0
  33. package/docs/superpowers/specs/2026-11-21-tri-host-takeover-design.md +363 -0
  34. package/docs/superpowers/specs/2026-11-22-settings-card-refactor-design.md +117 -0
  35. package/docs/superpowers/specs/2026-11-24-serve-lifecycle-design.md +155 -0
  36. package/docs/testing.md +92 -0
  37. package/docs/troubleshooting.md +258 -0
  38. package/dsh/client.js +2917 -0
  39. package/dsh/fetch-schema.json +1 -0
  40. package/dsh/index.js +2640 -0
  41. package/dsh/search-schema.json +65 -0
  42. package/dsh/spawnHidden.d.ts +7 -0
  43. package/dsh/spawnHidden.js +8 -0
  44. package/omp/extension.ts +331 -0
  45. package/package.json +95 -4
  46. package/skills/searchfuse/SKILL.md +139 -0
  47. package/skills/searchfuse/references/cli.md +78 -0
  48. package/skills/searchfuse/references/configure.md +405 -0
  49. package/skills/searchfuse/references/output-schema.md +182 -0
  50. package/skills/searchfuse/references/runtime.md +58 -0
  51. package/skills/searchfuse/scripts/run.ps1 +279 -0
  52. package/skills/searchfuse/scripts/run.sh +315 -0
@@ -0,0 +1,315 @@
1
+ #!/bin/sh
2
+ # searchfuse skill launcher (macOS / Linux).
3
+ #
4
+ # One stable action for the agent ("run searchfuse"); this script picks a working
5
+ # way to run it in the current environment. Written to POSIX sh so it runs under
6
+ # dash, busybox ash, and bash alike. Invoke it with `bash run.sh ...` (or plain
7
+ # `sh run.sh ...`) so a lost execute bit after a file copy never matters.
8
+ #
9
+ # Resolution order (kept identical in run.ps1):
10
+ # 1. A compatible searchfuse already on PATH -> run it directly.
11
+ # 2. npx present -> run the pinned npm version.
12
+ # 3. bunx present -> run the pinned version via Bun.
13
+ # 4. (phase B placeholder) a native artifact -> not published yet.
14
+ # 5. Nothing usable -> structured diagnosis, exit 78.
15
+ #
16
+ # It never writes PATH, never needs admin rights, never fetches a second script,
17
+ # and has no postinstall step.
18
+ set -eu
19
+
20
+ # --- Version constants: stamped by scripts/release.mjs at release time. --------
21
+ # Do not edit PINNED by hand; scripts/stamp.test.mjs asserts it equals the
22
+ # package.json version, and the release script rewrites it on every bump.
23
+ PKG="@wenaixi/searchfuse"
24
+ BIN="searchfuse"
25
+ PINNED="0.1.0"
26
+ # -------------------------------------------------------------------------------
27
+
28
+ NATIVE_NOTE="no native artifact is published for this tool yet; phase A ships npm launch paths only"
29
+
30
+ # Split "X.Y.Z" (extra suffix ignored) into the globals _MAJ, _MIN, _PAT.
31
+ # Any non-numeric component becomes 0 so integer tests below never abort.
32
+ parse_semver() {
33
+ _raw="$1"
34
+ _MAJ="${_raw%%.*}"
35
+ _rest="${_raw#*.}"
36
+ if [ "$_rest" = "$_raw" ]; then
37
+ _MIN=0
38
+ _PAT=0
39
+ else
40
+ _MIN="${_rest%%.*}"
41
+ _rest2="${_rest#*.}"
42
+ if [ "$_rest2" = "$_rest" ]; then _PAT=0; else _PAT="${_rest2%%.*}"; fi
43
+ fi
44
+ case "$_MAJ" in '' | *[!0-9]*) _MAJ=0 ;; esac
45
+ case "$_MIN" in '' | *[!0-9]*) _MIN=0 ;; esac
46
+ case "$_PAT" in '' | *[!0-9]*) _PAT=0 ;; esac
47
+ }
48
+
49
+ # Compatible = same major version as PINNED AND not older than PINNED.
50
+ # Same major keeps a globally installed CLI usable without a forced re-download;
51
+ # not-older refuses a stale build that predates the version this skill needs.
52
+ compatible() {
53
+ parse_semver "$1"
54
+ _f_maj=$_MAJ
55
+ _f_min=$_MIN
56
+ _f_pat=$_PAT
57
+ parse_semver "$PINNED"
58
+ [ "$_f_maj" = "$_MAJ" ] || return 1
59
+ if [ "$_f_min" -gt "$_MIN" ]; then return 0; fi
60
+ if [ "$_f_min" -lt "$_MIN" ]; then return 1; fi
61
+ [ "$_f_pat" -ge "$_PAT" ]
62
+ }
63
+
64
+ # First "X.Y.Z" token printed by `$BIN --version`.
65
+ cli_version() {
66
+ "$BIN" --version 2>/dev/null | head -n 1 |
67
+ sed -n 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p'
68
+ }
69
+
70
+ # The npx path runs the CLI on this machine's node, so npx is only usable when
71
+ # node itself meets the CLI's floor. An old node with a working npx used to be
72
+ # selected anyway, a path known to fail at run time.
73
+ NODE_FLOOR="22.19.0"
74
+ node_meets_floor() {
75
+ command -v node >/dev/null 2>&1 || return 1
76
+ _nv="$(node --version 2>/dev/null | sed 's/^v//')"
77
+ [ -n "$_nv" ] || return 1
78
+ parse_semver "$NODE_FLOOR"
79
+ _floor_maj="$_MAJ"
80
+ _floor_min="$_MIN"
81
+ parse_semver "$_nv"
82
+ if [ "$_MAJ" -gt "$_floor_maj" ]; then return 0; fi
83
+ if [ "$_MAJ" -lt "$_floor_maj" ]; then return 1; fi
84
+ [ "$_MIN" -ge "$_floor_min" ]
85
+ }
86
+
87
+ # Echo exactly one word: the chosen launch path.
88
+ resolve() {
89
+ if command -v "$BIN" >/dev/null 2>&1; then
90
+ _v="$(cli_version)"
91
+ if [ -n "$_v" ] && compatible "$_v"; then
92
+ echo "path"
93
+ return
94
+ fi
95
+ fi
96
+ if command -v npx >/dev/null 2>&1 && node_meets_floor; then
97
+ echo "npx"
98
+ return
99
+ fi
100
+ if command -v bunx >/dev/null 2>&1; then
101
+ echo "bunx"
102
+ return
103
+ fi
104
+ # Phase B goes here: check a versioned user cache, then download and verify a
105
+ # native artifact into it. Any such download must use curl (never a piped
106
+ # second script), which does not stamp quarantine / Mark-of-the-Web the way a
107
+ # browser does, matching design.md 8.3.
108
+ echo "none"
109
+ }
110
+
111
+ # Run the resolved CLI without exec, so its output can be captured (used to
112
+ # chain the CLI's own doctor). Passes every argument through untouched.
113
+ run_cli() {
114
+ case "$G_SEL" in
115
+ path) "$BIN" "$@" ;;
116
+ npx) npx --yes --package "$PKG@$PINNED" "$BIN" "$@" ;;
117
+ bunx) bunx --bun "$PKG@$PINNED" "$@" ;;
118
+ esac
119
+ }
120
+
121
+ detect_os() { uname -s 2>/dev/null | tr '[:upper:]' '[:lower:]'; }
122
+
123
+ detect_arch() {
124
+ _a="$(uname -m 2>/dev/null)"
125
+ case "$_a" in
126
+ x86_64 | amd64) echo "x64" ;;
127
+ aarch64 | arm64) echo "arm64" ;;
128
+ *) echo "$_a" ;;
129
+ esac
130
+ }
131
+
132
+ # Escape a value for a JSON string literal (backslash and double quote).
133
+ json_escape() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
134
+
135
+ # Render "null" for an empty value, else an escaped JSON string.
136
+ jstr() {
137
+ if [ -z "$1" ]; then printf 'null'; else printf '"%s"' "$(json_escape "$1")"; fi
138
+ }
139
+
140
+ # 1 -> true, anything else -> false.
141
+ jbool() { if [ "$1" = "1" ]; then printf 'true'; else printf 'false'; fi; }
142
+
143
+ # Probe the environment once into G_* globals shared by the emitters.
144
+ collect() {
145
+ G_OS="$(detect_os)"
146
+ G_ARCH="$(detect_arch)"
147
+
148
+ G_CLI_PRESENT=0
149
+ G_CLI_PATH=""
150
+ G_CLI_VER=""
151
+ G_CLI_COMPAT=0
152
+ if command -v "$BIN" >/dev/null 2>&1; then
153
+ G_CLI_PRESENT=1
154
+ G_CLI_PATH="$(command -v "$BIN")"
155
+ G_CLI_VER="$(cli_version)"
156
+ if [ -n "$G_CLI_VER" ] && compatible "$G_CLI_VER"; then G_CLI_COMPAT=1; fi
157
+ fi
158
+
159
+ G_NPX_PRESENT=0
160
+ G_NPX_PATH=""
161
+ if command -v npx >/dev/null 2>&1; then
162
+ G_NPX_PRESENT=1
163
+ G_NPX_PATH="$(command -v npx)"
164
+ fi
165
+
166
+ G_BUNX_PRESENT=0
167
+ G_BUNX_PATH=""
168
+ if command -v bunx >/dev/null 2>&1; then
169
+ G_BUNX_PRESENT=1
170
+ G_BUNX_PATH="$(command -v bunx)"
171
+ fi
172
+
173
+ G_NODE_PRESENT=0
174
+ G_NODE_VER=""
175
+ if command -v node >/dev/null 2>&1; then
176
+ G_NODE_PRESENT=1
177
+ G_NODE_VER="$(node --version 2>/dev/null | sed 's/^v//')"
178
+ fi
179
+
180
+ G_NODE_FLOOR_OK=0
181
+ if node_meets_floor; then G_NODE_FLOOR_OK=1; fi
182
+
183
+ G_SEL="$(resolve)"
184
+ }
185
+
186
+ # Build the nextSteps JSON array body (without the brackets) into G_NEXTSTEPS.
187
+ compute_next_steps() {
188
+ if [ "$G_SEL" = "none" ]; then
189
+ if [ "$G_NPX_PRESENT" = 1 ] && [ "$G_NODE_FLOOR_OK" = 0 ]; then
190
+ _s1="npx is present but node ${G_NODE_VER:-missing} is below the $NODE_FLOOR floor this CLI needs. Upgrade Node at https://nodejs.org, then re-run this launcher."
191
+ else
192
+ _s1="Install Node 22.19+ from https://nodejs.org so npx can run $PKG@$PINNED, then re-run this launcher."
193
+ fi
194
+ _s2="No JavaScript runtime? Install Bun from https://bun.sh to use bunx, or put a compatible $BIN (major ${PINNED%%.*}, at or above $PINNED) on PATH."
195
+ G_NEXTSTEPS="$(printf '"%s", "%s"' "$(json_escape "$_s1")" "$(json_escape "$_s2")")"
196
+ else
197
+ G_NEXTSTEPS=""
198
+ fi
199
+ }
200
+
201
+ # Emit the structured diagnosis. $1, when a JSON object, is embedded as cliDoctor.
202
+ emit_json() {
203
+ _chained="${1:-}"
204
+ compute_next_steps
205
+ printf '{\n'
206
+ printf ' "tool": %s,\n' "$(jstr "$BIN")"
207
+ printf ' "package": %s,\n' "$(jstr "$PKG")"
208
+ printf ' "pinnedVersion": %s,\n' "$(jstr "$PINNED")"
209
+ printf ' "os": %s,\n' "$(jstr "$G_OS")"
210
+ printf ' "arch": %s,\n' "$(jstr "$G_ARCH")"
211
+ printf ' "checked": {\n'
212
+ printf ' "pathCli": { "present": %s, "path": %s, "version": %s, "compatible": %s },\n' \
213
+ "$(jbool "$G_CLI_PRESENT")" "$(jstr "$G_CLI_PATH")" "$(jstr "$G_CLI_VER")" "$(jbool "$G_CLI_COMPAT")"
214
+ printf ' "npx": { "present": %s, "path": %s, "nodeMeetsFloor": %s },\n' "$(jbool "$G_NPX_PRESENT")" "$(jstr "$G_NPX_PATH")" "$(jbool "$G_NODE_FLOOR_OK")"
215
+ printf ' "bunx": { "present": %s, "path": %s },\n' "$(jbool "$G_BUNX_PRESENT")" "$(jstr "$G_BUNX_PATH")"
216
+ printf ' "node": { "present": %s, "version": %s }\n' "$(jbool "$G_NODE_PRESENT")" "$(jstr "$G_NODE_VER")"
217
+ printf ' },\n'
218
+ printf ' "nativeArtifact": { "available": false, "note": %s },\n' "$(jstr "$NATIVE_NOTE")"
219
+ printf ' "selected": %s,\n' "$(jstr "$G_SEL")"
220
+ printf ' "nextSteps": [%s],\n' "$G_NEXTSTEPS"
221
+ # First character of the captured output, via POSIX parameter expansion
222
+ # (cut -c1 would take the first char of every line, not of the whole string).
223
+ _first="${_chained%"${_chained#?}"}"
224
+ if [ -n "$_chained" ] && [ "$_first" = "{" ]; then
225
+ printf ' "cliDoctor": %s\n' "$_chained"
226
+ else
227
+ printf ' "cliDoctor": null\n'
228
+ fi
229
+ printf '}\n'
230
+ }
231
+
232
+ # Human-readable diagnosis for `doctor` without --json.
233
+ emit_text() {
234
+ printf '%s launcher diagnosis\n\n' "$BIN"
235
+ printf ' os / arch: %s / %s\n' "$G_OS" "$G_ARCH"
236
+ printf ' pinned version: %s (%s)\n' "$PINNED" "$PKG"
237
+ if [ "$G_CLI_PRESENT" = 1 ]; then
238
+ printf ' %s on PATH: %s (version %s, %s)\n' "$BIN" "$G_CLI_PATH" \
239
+ "${G_CLI_VER:-unknown}" "$([ "$G_CLI_COMPAT" = 1 ] && echo compatible || echo incompatible)"
240
+ else
241
+ printf ' %s on PATH: no\n' "$BIN"
242
+ fi
243
+ _npx_desc="no"
244
+ if [ "$G_NPX_PRESENT" = 1 ]; then
245
+ if [ "$G_NODE_FLOOR_OK" = 1 ]; then
246
+ _npx_desc="$G_NPX_PATH"
247
+ else
248
+ _npx_desc="$G_NPX_PATH (unusable: node ${G_NODE_VER:-missing} is below $NODE_FLOOR)"
249
+ fi
250
+ fi
251
+ printf ' npx: %s\n' "$_npx_desc"
252
+ printf ' bunx: %s\n' "$([ "$G_BUNX_PRESENT" = 1 ] && echo "$G_BUNX_PATH" || echo no)"
253
+ printf ' node: %s\n' "$([ "$G_NODE_PRESENT" = 1 ] && echo "${G_NODE_VER:-yes}" || echo no)"
254
+ printf ' selected path: %s\n' "$G_SEL"
255
+ if [ "$G_SEL" = "none" ]; then
256
+ printf '\nNo runtime can launch %s here. %s\n' "$BIN" "$NATIVE_NOTE"
257
+ printf 'Next steps:\n'
258
+ printf ' - Install Node 22.19+ from https://nodejs.org, then re-run this launcher.\n'
259
+ printf ' - Or install Bun from https://bun.sh, or put a compatible %s on PATH.\n' "$BIN"
260
+ fi
261
+ }
262
+
263
+ # `doctor [--json] [extra...]`: launcher selection diagnosis. When a CLI is
264
+ # resolvable, chain the CLI's own doctor (engine/config diagnosis) so one call
265
+ # reports both layers. Extra flags pass through to the chained CLI doctor.
266
+ doctor() {
267
+ collect
268
+ _json=0
269
+ for _a in "$@"; do
270
+ if [ "$_a" = "--json" ]; then _json=1; fi
271
+ done
272
+ if [ "$_json" = 1 ]; then
273
+ _chained=""
274
+ if [ "$G_SEL" != "none" ]; then
275
+ _chained="$(run_cli doctor "$@" 2>/dev/null)" || _chained=""
276
+ fi
277
+ emit_json "$_chained"
278
+ else
279
+ emit_text
280
+ if [ "$G_SEL" != "none" ]; then
281
+ printf '\n--- %s doctor ---\n' "$BIN"
282
+ run_cli doctor "$@" || true
283
+ fi
284
+ fi
285
+ }
286
+
287
+ # Default action: forward every argument to the resolved CLI, inheriting stdio
288
+ # and exit code. No usable runtime -> structured diagnosis on stderr, exit 78
289
+ # (EX_CONFIG) so the agent never mistakes the diagnosis for a result.
290
+ run() {
291
+ _sel="$(resolve)"
292
+ case "$_sel" in
293
+ path) exec "$BIN" "$@" ;;
294
+ npx) exec npx --yes --package "$PKG@$PINNED" "$BIN" "$@" ;;
295
+ bunx) exec bunx --bun "$PKG@$PINNED" "$@" ;;
296
+ none)
297
+ collect
298
+ emit_json "" >&2
299
+ exit 78
300
+ ;;
301
+ esac
302
+ }
303
+
304
+ case "${1:-}" in
305
+ doctor)
306
+ shift
307
+ doctor "$@"
308
+ ;;
309
+ where)
310
+ resolve
311
+ ;;
312
+ *)
313
+ run "$@"
314
+ ;;
315
+ esac