@signal4/s4 2.6.1 → 2.8.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 (76) hide show
  1. package/README.md +60 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +407 -196
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cli_args.d.ts +24 -0
  6. package/dist/cli_args.d.ts.map +1 -0
  7. package/dist/cli_args.js +130 -0
  8. package/dist/cli_args.js.map +1 -0
  9. package/dist/client.d.ts +103 -3
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +195 -23
  12. package/dist/client.js.map +1 -1
  13. package/dist/format.d.ts +103 -4
  14. package/dist/format.d.ts.map +1 -1
  15. package/dist/format.js +299 -64
  16. package/dist/format.js.map +1 -1
  17. package/dist/handler_types.d.ts +10 -0
  18. package/dist/handler_types.d.ts.map +1 -1
  19. package/dist/handler_types.js +25 -0
  20. package/dist/handler_types.js.map +1 -1
  21. package/dist/handlers/ads.js +4 -4
  22. package/dist/handlers/ads.js.map +1 -1
  23. package/dist/handlers/analyze.d.ts.map +1 -1
  24. package/dist/handlers/analyze.js +22 -6
  25. package/dist/handlers/analyze.js.map +1 -1
  26. package/dist/handlers/bookmarks.js +2 -2
  27. package/dist/handlers/bookmarks.js.map +1 -1
  28. package/dist/handlers/claim_detail.d.ts.map +1 -1
  29. package/dist/handlers/claim_detail.js +18 -10
  30. package/dist/handlers/claim_detail.js.map +1 -1
  31. package/dist/handlers/claims.d.ts.map +1 -1
  32. package/dist/handlers/claims.js +72 -27
  33. package/dist/handlers/claims.js.map +1 -1
  34. package/dist/handlers/count.d.ts +14 -0
  35. package/dist/handlers/count.d.ts.map +1 -0
  36. package/dist/handlers/count.js +158 -0
  37. package/dist/handlers/count.js.map +1 -0
  38. package/dist/handlers/explore.d.ts.map +1 -1
  39. package/dist/handlers/explore.js +56 -14
  40. package/dist/handlers/explore.js.map +1 -1
  41. package/dist/handlers/registry.d.ts.map +1 -1
  42. package/dist/handlers/registry.js +5 -1
  43. package/dist/handlers/registry.js.map +1 -1
  44. package/dist/handlers/reports.d.ts +6 -0
  45. package/dist/handlers/reports.d.ts.map +1 -1
  46. package/dist/handlers/reports.js +140 -26
  47. package/dist/handlers/reports.js.map +1 -1
  48. package/dist/handlers/search.d.ts.map +1 -1
  49. package/dist/handlers/search.js +80 -23
  50. package/dist/handlers/search.js.map +1 -1
  51. package/dist/handlers/timeline.d.ts.map +1 -1
  52. package/dist/handlers/timeline.js +14 -8
  53. package/dist/handlers/timeline.js.map +1 -1
  54. package/dist/http.js +25 -3
  55. package/dist/http.js.map +1 -1
  56. package/dist/index.js +2 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/provenance.d.ts +29 -2
  59. package/dist/provenance.d.ts.map +1 -1
  60. package/dist/provenance.js +63 -4
  61. package/dist/provenance.js.map +1 -1
  62. package/dist/server_core.d.ts +8 -1
  63. package/dist/server_core.d.ts.map +1 -1
  64. package/dist/server_core.js +90 -8
  65. package/dist/server_core.js.map +1 -1
  66. package/dist/speed.d.ts +40 -0
  67. package/dist/speed.d.ts.map +1 -0
  68. package/dist/speed.js +214 -0
  69. package/dist/speed.js.map +1 -0
  70. package/dist/surface.d.ts +7 -0
  71. package/dist/surface.d.ts.map +1 -0
  72. package/dist/surface.js +19 -0
  73. package/dist/surface.js.map +1 -0
  74. package/dist/types.d.ts +249 -15
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +3 -2
package/README.md CHANGED
@@ -26,6 +26,65 @@ This package contains three surfaces backed by one HTTP client:
26
26
  | CLI | `npx @signal4/s4 search ...` | `client.ts` | `handlers/` → text |
27
27
  | MCP server | `s4 --mcp` | `client.ts` | `handlers/` → text |
28
28
 
29
+ ## CLI quick start
30
+
31
+ ```bash
32
+ s4 collections # what you can scope to (omit --collection = whole corpus)
33
+ s4 search immigration policy -n 10 # unquoted multi-word topic; -n / -k / --limit = number of results
34
+ s4 search --keyword "border wall" -s "Tucker Carlson" --since 2024-06
35
+ s4 search tariffs --collection anglosphere --days 800 -o tariffs.md
36
+ s4 timeline tariffs --since 2023 -g quarter # day | week | month | quarter | year (calendar buckets)
37
+ s4 count tariffs --since 2025 --by month # segments · episodes · channels per month, no cap
38
+ s4 count "carbon tax" -m keyword --collection Canadian --by channel # exact; rank shows by what they said
39
+ s4 count "carbon tax" --vs "carbon pricing" --since 2024 --by quarter # several topics side by side
40
+ s4 count "Strong Borders Act" -m keyword --by episode --order date -n 100 # every matching episode, newest first
41
+ s4 count "carbon tax" -m keyword --since 2025 --by speaker # who speaks in the matching segments, names corroborated per episode
42
+ s4 top-speakers --topic tariffs -d 90 # same ranking, from the transcripts (not episode titles)
43
+ s4 entity-claims "Donald Trump" # every entity row of that name + merges; says what it matched
44
+ s4 search tariffs --keyword --since 2025 --page 3 # pages of -n; --all follows every page
45
+ s4 top-channels --topic Medicaid --country us -d 365 # channels ranked by what they said
46
+ s4 segment 42314442 # full text of a quote (seg:ID from search)
47
+ s4 --version
48
+ ```
49
+
50
+ Flags: `-n/-k/--limit` results · `--offset` skip · `-s` speaker · `-c` channel · `-d/--days` · `-m` mode ·
51
+ `-o/--out` file · `--since/--until` (or `--start/--end`; `2023`, `2023-06`, `2023-06-15`; on search, claims, timeline, trend, the claims-analysis commands, top-claims, top-channels, top-speakers) · `--collection` (every corpus command) · `--json`.
52
+ `--days` has no ceiling on search, claims, timeline and count; report commands cap at 365.
53
+ `count` groups with `--by` (day · week · month · quarter · year · channel · episode · speaker · language · country · platform · collection · lean);
54
+ keyword counts are exact, semantic counts are estimates at similarity ≥0.35, and every language is counted unless `--language` names some. Errors go to stderr with exit 1.
55
+
56
+ ## Paging
57
+
58
+ Every list command and tool pages the same way: `limit` + `offset` (CLI `-n` and `--offset`,
59
+ or `--page N`), and every answer ends with the next call (`next: offset:40`, CLI `--offset 40`).
60
+ `s4 <command> --all` follows the pages for you (up to 50). How deep each list goes:
61
+
62
+ | List | Depth |
63
+ |---|---|
64
+ | keyword search, `count` breakdowns, entity claims, claim observations | every match |
65
+ | semantic / hybrid quote search | rank 2,000 (`depth_reached` says when you hit it) |
66
+ | semantic / hybrid claims search | rank 1,000 |
67
+ | top speakers / channels / talk time | 200 (topic rankings: every match) |
68
+ | top claims | 100 |
69
+
70
+ Past a semantic depth, `--keyword` search or `count ... --by episode` list every match.
71
+ From TypeScript, `paginate()` walks the pages of any list call:
72
+
73
+ ```typescript
74
+ import { paginate, searchQuotes } from '@signal4/s4/client';
75
+ for await (const quote of paginate(searchQuotes, { topic: 'tariffs', mode: 'keyword', days: 365 })) { /* ... */ }
76
+ ```
77
+
78
+ ## Speed
79
+
80
+ Every MCP tool description and every `s4 <command> --help` starts with how long the call takes at
81
+ default settings: **instant** (<0.5s), **fast** (0.5–2.5s) or **slow** (>2.5s). Search, counts,
82
+ timelines and trends also say how that grows with the window, e.g.
83
+ `[fast ~1.5–2.5s; 12 months ~3–6.5s, all time ~5–11s]`. When a call is expected to take a while,
84
+ the MCP server sends a progress notice with the estimate as it starts (to clients that pass a
85
+ `progressToken`), and the CLI prints it to stderr. Answers that took longer than 2.5s end with
86
+ `Took Ns`. The numbers live in `src/speed.ts`, measured against the live API (signal4#292, #296).
87
+
29
88
  ## TypeScript Client
30
89
 
31
90
  For applications that need typed access to the Signal4 API (frontends, agents, pipelines, scripts):
@@ -80,6 +139,7 @@ The client reads from environment variables:
80
139
  - `searchClaims(params)` — Search extracted claims with stance and observation counts
81
140
  - `detectTrend(params)` — Compare recent vs baseline mention volume
82
141
  - `getTimeline(params)` — Topic mention volume over time
142
+ - `getCollections()` — Collections a key can scope to
83
143
 
84
144
  **Entities**
85
145
  - `searchSpeakers(query, limit?)` — Autocomplete speaker search
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAsgD7E,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA6E1C"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,6EAA6E;AA0qD7E,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA+G1C"}