@facthouse/mcp 0.30.0 → 0.32.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 (178) hide show
  1. package/README.md +60 -38
  2. package/dist/cli/cursor-listing.d.ts +55 -0
  3. package/dist/cli/cursor-listing.d.ts.map +1 -0
  4. package/dist/cli/cursor-listing.js +143 -0
  5. package/dist/cli/cursor-listing.js.map +1 -0
  6. package/dist/cli/eta.d.ts +15 -0
  7. package/dist/cli/eta.d.ts.map +1 -0
  8. package/dist/cli/eta.js +45 -0
  9. package/dist/cli/eta.js.map +1 -0
  10. package/dist/cli/init-backfill.d.ts +27 -5
  11. package/dist/cli/init-backfill.d.ts.map +1 -1
  12. package/dist/cli/init-backfill.js +122 -52
  13. package/dist/cli/init-backfill.js.map +1 -1
  14. package/dist/cli/init-knobs.d.ts +20 -3
  15. package/dist/cli/init-knobs.d.ts.map +1 -1
  16. package/dist/cli/init-knobs.js +60 -19
  17. package/dist/cli/init-knobs.js.map +1 -1
  18. package/dist/cli/init-wizard.d.ts +6 -2
  19. package/dist/cli/init-wizard.d.ts.map +1 -1
  20. package/dist/cli/init-wizard.js +14 -5
  21. package/dist/cli/init-wizard.js.map +1 -1
  22. package/dist/cli/init.d.ts +16 -6
  23. package/dist/cli/init.d.ts.map +1 -1
  24. package/dist/cli/init.js +45 -17
  25. package/dist/cli/init.js.map +1 -1
  26. package/dist/cli/inspect-match.d.ts +17 -0
  27. package/dist/cli/inspect-match.d.ts.map +1 -0
  28. package/dist/cli/inspect-match.js +100 -0
  29. package/dist/cli/inspect-match.js.map +1 -0
  30. package/dist/cli/inspect-payload.d.ts +20 -2
  31. package/dist/cli/inspect-payload.d.ts.map +1 -1
  32. package/dist/cli/inspect-payload.js +90 -38
  33. package/dist/cli/inspect-payload.js.map +1 -1
  34. package/dist/cli/inspect-progress.d.ts +14 -0
  35. package/dist/cli/inspect-progress.d.ts.map +1 -0
  36. package/dist/cli/inspect-progress.js +71 -0
  37. package/dist/cli/inspect-progress.js.map +1 -0
  38. package/dist/cli/inspect.d.ts.map +1 -1
  39. package/dist/cli/inspect.js +83 -67
  40. package/dist/cli/inspect.js.map +1 -1
  41. package/dist/cli/listings.d.ts +29 -0
  42. package/dist/cli/listings.d.ts.map +1 -0
  43. package/dist/cli/listings.js +118 -0
  44. package/dist/cli/listings.js.map +1 -0
  45. package/dist/cli/query.d.ts +3 -3
  46. package/dist/cli/query.d.ts.map +1 -1
  47. package/dist/cli/query.js +56 -11
  48. package/dist/cli/query.js.map +1 -1
  49. package/dist/cli/run.d.ts +13 -0
  50. package/dist/cli/run.d.ts.map +1 -1
  51. package/dist/cli/run.js +158 -39
  52. package/dist/cli/run.js.map +1 -1
  53. package/dist/cli/spend-dashboard.d.ts +1 -1
  54. package/dist/cli/spend-dashboard.d.ts.map +1 -1
  55. package/dist/cli/spend-dashboard.js +6 -5
  56. package/dist/cli/spend-dashboard.js.map +1 -1
  57. package/dist/cli/tty-progress.d.ts +19 -0
  58. package/dist/cli/tty-progress.d.ts.map +1 -0
  59. package/dist/cli/tty-progress.js +108 -0
  60. package/dist/cli/tty-progress.js.map +1 -0
  61. package/dist/config.d.ts +2 -0
  62. package/dist/config.d.ts.map +1 -1
  63. package/dist/config.js +4 -0
  64. package/dist/config.js.map +1 -1
  65. package/dist/db/embeddings.d.ts +2 -0
  66. package/dist/db/embeddings.d.ts.map +1 -1
  67. package/dist/db/embeddings.js +12 -0
  68. package/dist/db/embeddings.js.map +1 -1
  69. package/dist/db/extract-watermarks.d.ts +9 -0
  70. package/dist/db/extract-watermarks.d.ts.map +1 -1
  71. package/dist/db/extract-watermarks.js +10 -0
  72. package/dist/db/extract-watermarks.js.map +1 -1
  73. package/dist/db/stats.d.ts +13 -1
  74. package/dist/db/stats.d.ts.map +1 -1
  75. package/dist/db/stats.js +13 -1
  76. package/dist/db/stats.js.map +1 -1
  77. package/dist/embedding/provider.d.ts +13 -0
  78. package/dist/embedding/provider.d.ts.map +1 -1
  79. package/dist/embedding/provider.js +16 -8
  80. package/dist/embedding/provider.js.map +1 -1
  81. package/dist/identity.d.ts +3 -0
  82. package/dist/identity.d.ts.map +1 -1
  83. package/dist/identity.js +3 -0
  84. package/dist/identity.js.map +1 -1
  85. package/dist/intelligence/abort.d.ts +10 -0
  86. package/dist/intelligence/abort.d.ts.map +1 -0
  87. package/dist/intelligence/abort.js +18 -0
  88. package/dist/intelligence/abort.js.map +1 -0
  89. package/dist/intelligence/cli.d.ts +4 -0
  90. package/dist/intelligence/cli.d.ts.map +1 -1
  91. package/dist/intelligence/cli.js +46 -2
  92. package/dist/intelligence/cli.js.map +1 -1
  93. package/dist/intelligence/consolidate.d.ts +35 -3
  94. package/dist/intelligence/consolidate.d.ts.map +1 -1
  95. package/dist/intelligence/consolidate.js +167 -51
  96. package/dist/intelligence/consolidate.js.map +1 -1
  97. package/dist/intelligence/extract-prompt.d.ts +7 -0
  98. package/dist/intelligence/extract-prompt.d.ts.map +1 -1
  99. package/dist/intelligence/extract-prompt.js +26 -0
  100. package/dist/intelligence/extract-prompt.js.map +1 -1
  101. package/dist/intelligence/historic-selection.d.ts +20 -0
  102. package/dist/intelligence/historic-selection.d.ts.map +1 -0
  103. package/dist/intelligence/historic-selection.js +44 -0
  104. package/dist/intelligence/historic-selection.js.map +1 -0
  105. package/dist/intelligence/http.d.ts +2 -0
  106. package/dist/intelligence/http.d.ts.map +1 -1
  107. package/dist/intelligence/http.js +15 -1
  108. package/dist/intelligence/http.js.map +1 -1
  109. package/dist/intelligence/line-time.d.ts +15 -0
  110. package/dist/intelligence/line-time.d.ts.map +1 -0
  111. package/dist/intelligence/line-time.js +34 -0
  112. package/dist/intelligence/line-time.js.map +1 -0
  113. package/dist/intelligence/provider.d.ts +1 -0
  114. package/dist/intelligence/provider.d.ts.map +1 -1
  115. package/dist/intelligence/provider.js +1 -0
  116. package/dist/intelligence/provider.js.map +1 -1
  117. package/dist/intelligence/sampling.d.ts.map +1 -1
  118. package/dist/intelligence/sampling.js +4 -1
  119. package/dist/intelligence/sampling.js.map +1 -1
  120. package/dist/intelligence/stage-router.d.ts +1 -0
  121. package/dist/intelligence/stage-router.d.ts.map +1 -1
  122. package/dist/intelligence/stage-router.js +4 -1
  123. package/dist/intelligence/stage-router.js.map +1 -1
  124. package/dist/intelligence/steps.d.ts +14 -2
  125. package/dist/intelligence/steps.d.ts.map +1 -1
  126. package/dist/intelligence/steps.js +65 -2
  127. package/dist/intelligence/steps.js.map +1 -1
  128. package/dist/intelligence/types.d.ts +4 -1
  129. package/dist/intelligence/types.d.ts.map +1 -1
  130. package/dist/ipc/scheduler-ipc.d.ts +7 -3
  131. package/dist/ipc/scheduler-ipc.d.ts.map +1 -1
  132. package/dist/ipc/scheduler-ipc.js +23 -15
  133. package/dist/ipc/scheduler-ipc.js.map +1 -1
  134. package/dist/paths.d.ts +18 -3
  135. package/dist/paths.d.ts.map +1 -1
  136. package/dist/paths.js +38 -3
  137. package/dist/paths.js.map +1 -1
  138. package/dist/scheduler.d.ts +3 -2
  139. package/dist/scheduler.d.ts.map +1 -1
  140. package/dist/scheduler.js +3 -1
  141. package/dist/scheduler.js.map +1 -1
  142. package/dist/server.js +5 -3
  143. package/dist/server.js.map +1 -1
  144. package/dist/sources/copy.d.ts.map +1 -1
  145. package/dist/sources/copy.js +5 -0
  146. package/dist/sources/copy.js.map +1 -1
  147. package/dist/sources/cursor.d.ts.map +1 -1
  148. package/dist/sources/cursor.js +10 -2
  149. package/dist/sources/cursor.js.map +1 -1
  150. package/dist/sources/grok.d.ts +71 -0
  151. package/dist/sources/grok.d.ts.map +1 -0
  152. package/dist/sources/grok.js +326 -0
  153. package/dist/sources/grok.js.map +1 -0
  154. package/dist/sources/jsonl-copy.d.ts +8 -0
  155. package/dist/sources/jsonl-copy.d.ts.map +1 -1
  156. package/dist/sources/jsonl-copy.js +2 -2
  157. package/dist/sources/jsonl-copy.js.map +1 -1
  158. package/dist/sources/resolve.d.ts +7 -0
  159. package/dist/sources/resolve.d.ts.map +1 -1
  160. package/dist/sources/resolve.js +12 -5
  161. package/dist/sources/resolve.js.map +1 -1
  162. package/dist/tools/fact-manager.d.ts +7 -0
  163. package/dist/tools/fact-manager.d.ts.map +1 -1
  164. package/dist/tools/fact-manager.js +19 -2
  165. package/dist/tools/fact-manager.js.map +1 -1
  166. package/dist/tools/read-tools.d.ts +4 -1
  167. package/dist/tools/read-tools.d.ts.map +1 -1
  168. package/dist/tools/read-tools.js +14 -7
  169. package/dist/tools/read-tools.js.map +1 -1
  170. package/dist/tools/session-manager.js +1 -1
  171. package/dist/tools/session-manager.js.map +1 -1
  172. package/dist/types/config.d.ts +18 -8
  173. package/dist/types/config.d.ts.map +1 -1
  174. package/dist/types/config.js +15 -2
  175. package/dist/types/config.js.map +1 -1
  176. package/dist/types/data.d.ts +1 -1
  177. package/dist/types/data.d.ts.map +1 -1
  178. package/package.json +5 -4
package/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  <img src="brand/mark.png" width="128" align="right" alt="Facthouse">
4
4
 
5
- A local memory engine any AI tool can use.
6
-
7
- Not Mem0's hosted OpenMemory MCP at mcp.mem0.ai.
5
+ Facthouse is a local memory engine for AI tools. Most “memory” products index chat logs. Facthouse takes agent activity - messages, tool use, and other MCP traffic - and applies neuroscience-inspired consolidation so it moves through **Data** (what happened in the session) → **Information** (extracted facts) → **Knowledge** (integrated beliefs on an entity graph). During this process, Facthouse links entities, drops duplicates, reconciles conflicts, and supersedes what is out of date. Vector embeddings add optional semantic search on top of that graph. The store is a SQLite file on your disk.
8
6
 
9
7
  [![npm](https://img.shields.io/npm/v/@facthouse/mcp.svg)](https://www.npmjs.com/package/@facthouse/mcp)
10
8
  [![CI](https://github.com/gordonkjlee/facthouse/actions/workflows/ci.yml/badge.svg)](https://github.com/gordonkjlee/facthouse/actions/workflows/ci.yml)
@@ -16,24 +14,20 @@ Not Mem0's hosted OpenMemory MCP at mcp.mem0.ai.
16
14
 
17
15
  Needs Node 22.5 or 24+.
18
16
 
19
- <!-- x-release-please-start-version -->
20
17
  ```bash
21
- npm install -g @facthouse/mcp@0.30.0
18
+ npx -y @facthouse/mcp
22
19
  facthouse init
23
20
  ```
24
- <!-- x-release-please-end -->
25
-
26
- If npm install -g fails because a command named mcp already exists, remove that leftover command and retry.
27
21
 
28
22
  `facthouse init --web` is the same setup as a browser form — it prints a 127.0.0.1 URL and does not open a browser.
29
23
 
30
- Press Enter to accept each default (copy = Claude Code or Cursor session logs on disk; type record if the assistant should save facts). If you picked copy, init asks whether to copy existing logs, then whether to extract and integrate. Init prints an MCP snippet — paste it into the client and restart.
24
+ Press Enter to accept each default (copy = Claude Code, Cursor or Grok Build session logs on disk; type record if the assistant should save facts). If you picked copy, init asks whether to copy existing logs, then whether to extract and integrate. Init prints an MCP snippet as soon as the store is written — add it to the client's MCP config while copy/extract run. Restart the client when init finishes.
31
25
 
32
26
  In the client, state something durable in ordinary conversation — there is no remember command.
33
27
 
34
28
  Ask it back in the next session, or `facthouse search`. That is the store.
35
29
 
36
- Copy from Claude Code or Cursor logs, or record from any MCP client: [How conversations get in](#how-conversations-get-in). Replay: [facthouse.dev/demo.html](https://facthouse.dev/demo.html). CLI: [below](#cli).
30
+ Copy from Claude Code, Cursor or Grok Build logs, or record from any MCP client: [How conversations get in](#how-conversations-get-in). Replay: [facthouse.dev/demo.html](https://facthouse.dev/demo.html). CLI: [below](#cli).
37
31
 
38
32
  ## What you get
39
33
 
@@ -53,7 +47,27 @@ One SQLite database. Three tables in it, not three databases: **Data** (what hap
53
47
 
54
48
  FTS5 (words) and optional embeddings (meaning) are indexes of **K**. They are not a second store. Semantic search is off unless you turn it on: `search "shellfish"` finds a shellfish fact, `search "food"` does not, until you choose an embedding model — a model is an opinion about what “similar” means.
55
49
 
56
- Two speeds. **Extract** turns new transcript lines into self-contained facts. **Integrate** fits them into what the store already knows: domains, entities, duplicates, contradictions, the graph. `consolidate` runs copy, extract, and integrate together — in the server at session start and at compaction, or by hand from the CLI. Extract is capped at 50 lines per run, so a first backfill is never spent on the lot; each automatic run extracts facts from the oldest 50 lines. The MCP server copies the raw log on a call; it does not extract then. Consolidation does not invent a sentence nobody said.
50
+ Two speeds. **Copy** tails named transcripts into Data. **Extract** turns new transcript lines into self-contained facts (D→I). **Integrate** fits them into what the store already knows: domains, entities, duplicates, contradictions, the graph (I→K). `consolidate` is the umbrella: copy, extract, and integrate together. Extract is capped at 50 lines per run, so a first backfill is never spent on the lot; when extract runs, it takes the oldest 50 lines. Consolidation does not invent a sentence nobody said.
51
+
52
+ A hook cannot call MCP tools — those exist only on the assistant’s connection — and it must not wait for a model pass. So it does not invoke `consolidate`. It runs `facthouse notify …`, which tells the **already-running** server that a moment happened and returns at once. `consolidate` is the pipeline verb (MCP tool or CLI); the caller waits. `notify compaction` is that verb asked of the live server, asynchronously. `notify threshold` is a different policy (extract only, if due).
53
+
54
+ **Automatic**
55
+
56
+ | When | Copy | Extract (D→I) | Integrate (I→K) |
57
+ |------|------|---------------|-----------------|
58
+ | Facthouse MCP server starts | yes | yes (cap 50) | yes |
59
+ | A Facthouse tool or resource is called | yes, if sources named and JSONL grew | no | no |
60
+ | Facthouse MCP process exits | no | no | yes |
61
+
62
+ **Callable**
63
+
64
+ | Call | From | Copy | Extract (D→I) | Integrate (I→K) |
65
+ |------|------|------|---------------|-----------------|
66
+ | `consolidate` | MCP tool or CLI. Caller waits. | yes | yes (cap 50) | yes |
67
+ | `facthouse notify compaction` | Other process (recommended PreCompact; we do not install). Does not wait. | yes | yes (cap 50) | yes |
68
+ | `facthouse notify threshold` | Other process. Does not wait. Not a copy-store hook. | no | yes, if due (cap 50) | no |
69
+
70
+ On a default copy store with no extra hooks, only the automatic table runs: Facthouse starts (all three), copy on each Facthouse tool or resource call if named sources grew, and integrate on a clean process exit. Closing a chat window may skip the exit row; the next start still consolidates. Due on threshold means at least 10 unexamined lines and two minutes since the last gated run. `consolidate --all` lifts the extract cap. Compaction is recommended PreCompact (`notify compaction`): same three steps as `consolidate`, on the running server, without waiting. We do not install the hook. Not a Stop hook. `record` wakes threshold extract on a record store — do not install record hooks on a copy store.
57
71
 
58
72
  Storage needs Node. Intelligence needs a language model. By default that is the [Claude Code CLI](https://github.com/anthropics/claude-code) on your existing subscription. Without it, consolidation falls back to a built-in heuristic that **does not extract facts from transcripts**. `capture_fact` still stores facts, with no entities and no domain routing.
59
73
 
@@ -63,19 +77,19 @@ Two ways. Pick one per store.
63
77
 
64
78
  | | Copy from transcripts | The assistant records |
65
79
  |---|---|---|
66
- | Who | Claude Code or Cursor (session logs on disk, under the client home) | Any MCP client (Grok, Desktop, …) |
80
+ | Who | Claude Code, Cursor or Grok Build (session logs on disk, under the client home) | Any MCP client with no log on disk (Desktop, …) |
67
81
  | How | Name a source; Facthouse copies new lines from those logs into the store | Empty `sources`; the assistant calls `capture_fact` |
68
82
  | First run | TTY walk-through, pick **copy**, set cwd; init asks whether to copy existing logs, then whether to extract and integrate | TTY walk-through, pick **record** |
69
83
 
70
- On a copy store, capture_fact is a correction for every MCP client, not only the one that writes JSONL. Grok has no transcript adapter — do not put Claude Code on copy and Grok on the same store expecting Grok to record.
84
+ On a copy store, capture_fact is a correction for every MCP client, not only the one that writes JSONL. To use Claude Code and Grok Build on one store, name a `claude-code` source and a `grok` source with the same `cwd`: both copy in, and neither is asked to record. Do not also install record hooks on that store.
71
85
 
72
86
  ```bash
73
87
  facthouse init
74
88
  ```
75
89
 
76
- Pick copy, set cwd. Init asks whether to copy existing logs, then whether to extract and integrate (Enter = all copied lines). Decline extract to do that later with `facthouse consolidate` (`--all` takes the whole backlog). After that, the server copies new lines when it handles a call.
90
+ Pick copy, set cwd. Init asks whether to copy existing logs, then whether to extract and integrate (Enter = all copied lines; a selection of 500 or more asks you to type the choice again). Decline extract to do that later with `facthouse consolidate` (`--all` takes remaining unexamined lines, not ones skipped as outside a 7-day or 30-day window). After that, the server copies new lines when it handles a Facthouse call. Extract and integrate follow the table in [How it works](#how-it-works).
77
91
 
78
- Compact (optional): `facthouse notify compaction` — not a turn-end Stop hook.
92
+ Compact (recommended): `facthouse notify compaction` — we do not install the hook. Not a turn-end Stop hook.
79
93
 
80
94
  ## MCP
81
95
 
@@ -119,19 +133,21 @@ Both are read-only views over the same database the tools query. Clients that ne
119
133
 
120
134
  The MCP JSON starts the server via npx and does not need a global install. npm install -g puts facthouse on PATH for init, settings, stats, and inspect. The same CLI without PATH is npx -y -p "@facthouse/mcp" -- facthouse — pin the version; quote the package so PowerShell does not splat. -p and -- stop an older global binary winning. npx -y @facthouse/mcp with no -p / facthouse is the server; do not run it as a shell command for init, settings, or stats. The MCP paste starts the server. It does not put facthouse on PATH. To inspect the file from a terminal, see CLI below.
121
135
 
122
- These CLI commands work in bash, zsh, and PowerShell. Quote @facthouse/mcp in PowerShell. Git Bash /c/... paths are not PowerShell; use C:/... and pass --data instead of cd or export. In Git Bash, quote a backslash path or write C:/... — unquoted \ is an escape. ~/ is expanded on every platform. WSL uses /mnt/c/.... FACTHOUSE_DATA on an MCP snippet applies only to that server process. A terminal facthouse command needs --data, or FACTHOUSE_DATA in the environment that shell inherits. Hooks do not see mcp.json env.
136
+ These CLI commands work in bash, zsh, and PowerShell. Quote @facthouse/mcp in PowerShell. Git Bash /c/... paths are not PowerShell; use C:/... and pass --data instead of cd or export. In Git Bash, quote a backslash path or write C:/... — unquoted \ is an escape. ~/ is expanded on every platform. WSL uses /mnt/c/.... FACTHOUSE_DATA on an MCP snippet applies only to that server process. A terminal facthouse command needs --data, FACTHOUSE_DATA in the environment that shell inherits, or a .facthouse store in this project. Hooks do not see mcp.json env.
123
137
 
124
138
  <!-- x-release-please-start-version -->
125
139
  ```bash
126
- npm install -g @facthouse/mcp@0.30.0
140
+ npm install -g @facthouse/mcp@0.32.0
127
141
  facthouse init --yes
128
142
  ```
129
143
 
144
+ If npm install -g fails because a command named mcp already exists, remove that leftover command and retry.
145
+
130
146
  ```bash
131
- npx -y -p "@facthouse/mcp@0.30.0" -- facthouse init --yes
132
- npx -y -p "@facthouse/mcp@0.30.0" -- facthouse settings --json
133
- npx -y -p "@facthouse/mcp@0.30.0" -- facthouse stats
134
- npx -y -p "@facthouse/mcp@0.30.0" -- facthouse inspect
147
+ npx -y -p "@facthouse/mcp@0.32.0" -- facthouse init --yes
148
+ npx -y -p "@facthouse/mcp@0.32.0" -- facthouse settings --json
149
+ npx -y -p "@facthouse/mcp@0.32.0" -- facthouse stats
150
+ npx -y -p "@facthouse/mcp@0.32.0" -- facthouse inspect
135
151
  ```
136
152
  <!-- x-release-please-end -->
137
153
 
@@ -192,7 +208,7 @@ facthouse record --role user --event-type message --content "hello world"
192
208
  # --content Event content (or pipe via stdin)
193
209
  # --speaker Named participant when the transcript has one
194
210
  # --session-id Target session (default: most recent)
195
- # --data Data directory (default: ~/.facthouse or FACTHOUSE_DATA)
211
+ # --data Data directory (default: FACTHOUSE_DATA, a .facthouse store in this project, or ~/.facthouse)
196
212
  ```
197
213
 
198
214
  #### `facthouse consolidate`
@@ -213,7 +229,7 @@ facthouse consolidate --limit 200 # extract the oldest 200
213
229
  # Extract is capped at 50 lines per run so a first backfill is never spent on
214
230
  # the lot; the run says how many remain. --all lifts the cap, --limit N sets it.
215
231
  # --json print the result object instead of the summary
216
- # --data Data directory (default: ~/.facthouse or FACTHOUSE_DATA)
232
+ # --data Data directory (default: FACTHOUSE_DATA, a .facthouse store in this project, or ~/.facthouse)
217
233
  ```
218
234
 
219
235
  Honours the configured provider (by default `claude -p`). Empty `sources` makes the copy step a no-op. Set `cwd` on the source unless you intend to copy every project group. Do not also run `record` hooks on a store with named sources.
@@ -223,11 +239,11 @@ Honours the configured provider (by default `claude -p`). Empty `sources` makes
223
239
  Tell the running MCP server that a moment happened. The server decides what to run and does it in the background, so a hook returns at once:
224
240
 
225
241
  ```bash
226
- facthouse notify compaction # the client window is about to collapse: copy, extract, integrate now
242
+ facthouse notify compaction # client about to compact: copy new JSONL, extract, integrate (does not wait)
227
243
  facthouse notify threshold # events arrived: extract if the threshold is due
228
244
 
229
245
  # Options:
230
- # --data Data directory (default: ~/.facthouse or FACTHOUSE_DATA)
246
+ # --data Data directory (default: FACTHOUSE_DATA, a .facthouse store in this project, or ~/.facthouse)
231
247
  ```
232
248
 
233
249
  No server listening is not an error: the command says so and exits 0, and the next session start covers it. This is what the PreCompact hook calls.
@@ -243,7 +259,7 @@ facthouse search "coffee" --json
243
259
  # --domain Prioritise a domain. Biases ranking; does not filter
244
260
  # --limit Maximum results (default: 20)
245
261
  # --json Emit the raw search payload
246
- # --data Data directory (default: ~/.facthouse or FACTHOUSE_DATA)
262
+ # --data Data directory (default: FACTHOUSE_DATA, a .facthouse store in this project, or ~/.facthouse)
247
263
  ```
248
264
 
249
265
  `--domain` **biases ranking rather than filtering.** A hard filter would hide a fact filed under a near-synonym.
@@ -285,12 +301,12 @@ A non-default data directory prints a distinct MCP server name so two stores can
285
301
  "mcpServers": {
286
302
  "facthouse-personal": {
287
303
  "command": "npx",
288
- "args": ["-y", "@facthouse/mcp@0.30.0"],
304
+ "args": ["-y", "@facthouse/mcp@0.32.0"],
289
305
  "env": { "FACTHOUSE_DATA": "C:\\Users\\alex\\.facthouse-personal" }
290
306
  },
291
307
  "facthouse-work": {
292
308
  "command": "npx",
293
- "args": ["-y", "@facthouse/mcp@0.30.0"],
309
+ "args": ["-y", "@facthouse/mcp@0.32.0"],
294
310
  "env": { "FACTHOUSE_DATA": "C:\\Users\\alex\\.facthouse-work" }
295
311
  }
296
312
  }
@@ -316,7 +332,7 @@ Example — placeholders only; do not put a real password in a committed file:
316
332
  "mcpServers": {
317
333
  "facthouse": {
318
334
  "command": "npx",
319
- "args": ["-y", "@facthouse/mcp@0.30.0"],
335
+ "args": ["-y", "@facthouse/mcp@0.32.0"],
320
336
  "env": {
321
337
  "FACTHOUSE_DATA": "C:\\Users\\alex\\.facthouse-work",
322
338
  "FACTHOUSE_STORAGE": "postgres",
@@ -332,7 +348,7 @@ Example — placeholders only; do not put a real password in a committed file:
332
348
 
333
349
  Choose one mechanism per store.
334
350
 
335
- **Recommended — copy.** Name a `claude-code` or `cursor` source (set `cwd`) and run `facthouse consolidate` from the CLI first. The MCP server also copies at session start and when it handles a call. Grok and Codex are later adapters. Unknown `kind` values are rejected.
351
+ **Recommended — copy.** Name a `claude-code`, `cursor` or `grok` source (set `cwd`) and run `facthouse consolidate` from the CLI first. The MCP server also copies at session start and when it handles a call. Codex is a later adapter. Unknown `kind` values are rejected.
336
352
 
337
353
  ```json
338
354
  {
@@ -362,14 +378,16 @@ To skip the wizard (record only — no transcript copy), paste this. The server
362
378
  "mcpServers": {
363
379
  "facthouse": {
364
380
  "command": "npx",
365
- "args": ["-y", "@facthouse/mcp@0.30.0"]
381
+ "args": ["-y", "@facthouse/mcp@0.32.0"]
366
382
  }
367
383
  }
368
384
  }
369
385
  ```
370
386
  <!-- x-release-please-end -->
371
387
 
372
- ### Hooks (after the first consolidate)
388
+ ### Hooks
389
+
390
+ PreCompact `notify compaction` is the useful one: when the client is about to compact, a short-lived hook tells the **running** server, and the hook returns at once. The server copies new JSONL lines, then extracts and integrates — compaction does not delete the transcript, and the hook does not photocopy the live window. Init prints this JSON with `--data` filled in. Paste into Claude Code `.claude/settings.json` (user or project). We do not install it. Do not install a Stop hook. Do not install record hooks on this store — both write the same rows.
373
391
 
374
392
  `mcp.json` `env` is **not** visible to hooks. Pass the same `--data` (or set `FACTHOUSE_DATA` in the environment the client itself inherits). The command must invoke the CLI (`facthouse`), never the server binary. `npx -y @facthouse/mcp` with no `-p` / `facthouse` starts the MCP **server** and hangs a hook. Pin the package version, quote it if the hook runs PowerShell, and put `--` before `facthouse` so a globally installed older binary on PATH cannot win.
375
393
 
@@ -385,7 +403,7 @@ To skip the wizard (record only — no transcript copy), paste this. The server
385
403
  "hooks": [
386
404
  {
387
405
  "type": "command",
388
- "command": "npx -y -p @facthouse/mcp@0.30.0 -- facthouse notify compaction --data /absolute/path/to/the-same-store"
406
+ "command": "npx -y -p @facthouse/mcp@0.32.0 -- facthouse notify compaction --data /absolute/path/to/the-same-store"
389
407
  }
390
408
  ]
391
409
  }
@@ -468,7 +486,7 @@ Throwaway store, not the capture path for a real Claude Code or Cursor home. The
468
486
  <!-- x-release-please-start-version -->
469
487
  ```bash
470
488
  export FACTHOUSE_DATA=/tmp/facthouse-demo
471
- om() { npx -y -p "@facthouse/mcp@0.30.0" -- facthouse "$@"; }
489
+ om() { npx -y -p "@facthouse/mcp@0.32.0" -- facthouse "$@"; }
472
490
 
473
491
  om init --yes
474
492
 
@@ -483,7 +501,7 @@ om stats
483
501
 
484
502
  ```powershell
485
503
  $env:FACTHOUSE_DATA = Join-Path $env:TEMP "facthouse-demo"
486
- function om { npx -y -p "@facthouse/mcp@0.30.0" -- facthouse @args }
504
+ function om { npx -y -p "@facthouse/mcp@0.32.0" -- facthouse @args }
487
505
  om init --yes
488
506
  om record --role user --content "I prefer dark mode in every editor, and I never want telemetry enabled."
489
507
  om record --role user --content "I am allergic to shellfish, so avoid seafood restaurants when booking anything."
@@ -502,7 +520,7 @@ Facthouse's tool descriptions tell assistants when to search and when a correcti
502
520
 
503
521
  ### Without configuration
504
522
 
505
- Claude Code or Cursor: name a `sources` entry (set `cwd`) and run `facthouse consolidate` from the CLI first. MCP session start also copies. `capture_fact` is there if the assistant needs to correct or add something copy-plus-extraction will not produce.
523
+ Claude Code, Cursor or Grok Build: name a `sources` entry (set `cwd`) and run `facthouse consolidate` from the CLI first. MCP session start also copies. `capture_fact` is there if the assistant needs to correct or add something copy-plus-extraction will not produce.
506
524
 
507
525
  Clients with no copy adapter still rely on `log_event` / `capture_fact` until their adapter exists.
508
526
 
@@ -526,7 +544,7 @@ Create `.claude/rules/facthouse.md` in your project (or `~/.claude/rules/facthou
526
544
  # Facthouse
527
545
 
528
546
  - Conversations are copied from the named Claude Code source (first backfill: `facthouse consolidate` on the CLI)
529
- - Do not install record hooks on this store
547
+ - Do not install record hooks on this store — both write the same rows.
530
548
  - Identity context loads automatically from the `memory://profile` resource — no tool call needed
531
549
  - Before answering questions this store might already know, call `search_knowledge`
532
550
  - Call `capture_fact` only to correct or add something that is not in the transcript
@@ -548,18 +566,22 @@ To allow Facthouse tools without per-call approval prompts, add to the `permissi
548
566
 
549
567
  ### Cursor / Windsurf
550
568
 
569
+ On [Cursor Directory](https://cursor.directory/plugins/facthouse), **Add to Cursor** is per component: click it on the MCP server and again on the rule. That boots a record store at `~/.facthouse` — no `facthouse init`. The Hooks tab is Copy into `~/.cursor/hooks.json`, not Add to Cursor. To copy Agent transcripts, run `facthouse init`, pick copy, kind cursor.
570
+
551
571
  Add to `.cursorrules` (Cursor) or `.windsurfrules` (Windsurf) in your project root:
552
572
 
553
573
  ```
554
574
  When the facthouse MCP server is available:
575
+ - At the start of every conversation, before answering, call get_session_context unless you already loaded the memory://briefing resource. That call returns the same working briefing the resource would have injected. Tools-only clients never fetch resources.
555
576
  - Before answering questions this store might already know, call search_knowledge
556
577
  - To find out everything known about a particular person, project, or thing, call get_entity
557
578
  - Call capture_fact only to correct or add something copy or extraction missed
558
- - When context is getting long, call consolidate to process pending facts before they are lost
559
579
  ```
560
580
 
561
581
  Cursor and Windsurf consume tools but not resources, so `memory://profile` will not load on its own there. Cursor conversations themselves are copied with `kind: "cursor"` (JSONL under `~/.cursor/projects/`, not the SQLite composer store).
562
582
 
583
+ Grok Build conversations are copied with `kind: "grok"`: `chat_history.jsonl` under `~/.grok/sessions/` (or `GROK_HOME`), not `updates.jsonl`. Reasoning, system lines, injected reminders and sub-agent runs (sessions a parent lists under its `subagents/`) are skipped.
584
+
563
585
  ### Claude Desktop / other MCP clients
564
586
 
565
587
  No copy adapter yet. Tool descriptions handle search and optional `capture_fact`; conversations are not tailed until a later adapter exists.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Cursor Directory listing payload. One definition for the
3
+ * https://cursor.directory/plugins/facthouse form.
4
+ *
5
+ * Dump (after build): `node dist/cli/cursor-listing.js`
6
+ * Inventory / other surfaces: `node dist/cli/listings.js`
7
+ * Do not add a repo-root `.mcp.json` so the directory can scrape this repo.
8
+ * Semantic search and Postgres stay out of the paste JSON — they are store
9
+ * knobs, not login fields.
10
+ */
11
+ import { CURSOR_DIRECTORY_ORIGIN } from "./listings.js";
12
+ /** Same words as README Quick Start. `package.json` `engines.node` is the constraint. */
13
+ export declare const NODE_REQUIREMENT_LINE = "Needs Node 22.5 or 24+.";
14
+ /**
15
+ * MCP-only listing store. No `FACTHOUSE_DATA` on the paste, so the server
16
+ * is this directory. The Hooks JSON uses the same path as `--data`.
17
+ */
18
+ export declare const LISTING_DEFAULT_DATA_DIR = "~/.facthouse";
19
+ export { CURSOR_DIRECTORY_ORIGIN };
20
+ /**
21
+ * Tools-only client rules. README § Cursor / Windsurf repeats this block.
22
+ * Cursor Directory gets it as the Rules field, not inside Setup.
23
+ * First bullet is `SESSION_BOOTSTRAP_INSTRUCTIONS` — one definition.
24
+ */
25
+ export declare const CURSOR_RULES_BODY = "When the facthouse MCP server is available:\n- At the start of every conversation, before answering, call get_session_context unless you already loaded the memory://briefing resource. That call returns the same working briefing the resource would have injected. Tools-only clients never fetch resources.\n- Before answering questions this store might already know, call search_knowledge\n- To find out everything known about a particular person, project, or thing, call get_entity\n- Call capture_fact only to correct or add something copy or extraction missed";
26
+ export interface CursorDirectoryListing {
27
+ origin: string;
28
+ title: string;
29
+ homepage: string;
30
+ repository: string;
31
+ description: string;
32
+ /** Valid JSON. Default store; no env, no embedding keys. */
33
+ mcpJson: string;
34
+ /** Cursor-specific setup. Not an account login. */
35
+ setup: string;
36
+ /** Directory Rules field. Not Setup. */
37
+ rules: string;
38
+ /**
39
+ * Directory Hooks tab. Copy into `~/.cursor/hooks.json` — that tab is
40
+ * Copy, not Add to Cursor.
41
+ */
42
+ hooks: string;
43
+ }
44
+ export declare function cursorListingDescription(): string;
45
+ export declare function cursorListingMcpJson(version?: string): string;
46
+ /**
47
+ * Same argv as init `precompactHookJson` (`notify compaction --data`).
48
+ * Cursor Directory Hooks are Copy, not an installed plugin script.
49
+ */
50
+ export declare function cursorListingHookCommand(version?: string): string;
51
+ export declare function cursorListingHooksJson(version?: string): string;
52
+ export declare function cursorListingSetup(): string;
53
+ export declare function cursorDirectoryListing(version?: string): CursorDirectoryListing;
54
+ export declare function formatCursorDirectoryListing(listing?: CursorDirectoryListing): string;
55
+ //# sourceMappingURL=cursor-listing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-listing.d.ts","sourceRoot":"","sources":["../../src/cli/cursor-listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,qjBAIiD,CAAC;AAEhF,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAUD,wBAAgB,wBAAwB,IAAI,MAAM,CAQjD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAW/D;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAW3C;AAED,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAa/E;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,sBAAiD,GACzD,MAAM,CAgCR"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Cursor Directory listing payload. One definition for the
3
+ * https://cursor.directory/plugins/facthouse form.
4
+ *
5
+ * Dump (after build): `node dist/cli/cursor-listing.js`
6
+ * Inventory / other surfaces: `node dist/cli/listings.js`
7
+ * Do not add a repo-root `.mcp.json` so the directory can scrape this repo.
8
+ * Semantic search and Postgres stay out of the paste JSON — they are store
9
+ * knobs, not login fields.
10
+ */
11
+ import path from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+ import { GITHUB_REPO, HOMEPAGE, LOCKUP, PRODUCT_NAME, cliDataArg, npmPackageSpec, pathFreeCli, } from "../identity.js";
14
+ import { SESSION_BOOTSTRAP_INSTRUCTIONS } from "../tools/resources.js";
15
+ import { mcpConfigSnippet } from "./init.js";
16
+ import { INIT_PROMPTS, silentEmbeddingProvider } from "./init-knobs.js";
17
+ import { CURSOR_DIRECTORY_ORIGIN } from "./listings.js";
18
+ import { packageVersion } from "./package-version.js";
19
+ /** Same words as README Quick Start. `package.json` `engines.node` is the constraint. */
20
+ export const NODE_REQUIREMENT_LINE = "Needs Node 22.5 or 24+.";
21
+ /**
22
+ * MCP-only listing store. No `FACTHOUSE_DATA` on the paste, so the server
23
+ * is this directory. The Hooks JSON uses the same path as `--data`.
24
+ */
25
+ export const LISTING_DEFAULT_DATA_DIR = "~/.facthouse";
26
+ export { CURSOR_DIRECTORY_ORIGIN };
27
+ /**
28
+ * Tools-only client rules. README § Cursor / Windsurf repeats this block.
29
+ * Cursor Directory gets it as the Rules field, not inside Setup.
30
+ * First bullet is `SESSION_BOOTSTRAP_INSTRUCTIONS` — one definition.
31
+ */
32
+ export const CURSOR_RULES_BODY = `When the facthouse MCP server is available:
33
+ - ${SESSION_BOOTSTRAP_INSTRUCTIONS}
34
+ - Before answering questions this store might already know, call search_knowledge
35
+ - To find out everything known about a particular person, project, or thing, call get_entity
36
+ - Call capture_fact only to correct or add something copy or extraction missed`;
37
+ function requiredVersion(version) {
38
+ const resolved = version ?? packageVersion();
39
+ if (!resolved) {
40
+ throw new Error("package.json version is missing; cannot pin the MCP snippet");
41
+ }
42
+ return resolved;
43
+ }
44
+ export function cursorListingDescription() {
45
+ return (`${LOCKUP} In Cursor it turns Agent chats into a graph of people, projects, and decisions — duplicates dropped, contradictions superseded. ` +
46
+ `Click Add to Cursor on the MCP server and on the rule. ${NODE_REQUIREMENT_LINE} ` +
47
+ `No account and no init; the store is ${LISTING_DEFAULT_DATA_DIR}. ` +
48
+ `Copy transcripts: ${INIT_PROMPTS.copyRecipe} Kind cursor. ` +
49
+ `Compaction: copy the Hooks tab into ~/.cursor/hooks.json.`);
50
+ }
51
+ export function cursorListingMcpJson(version) {
52
+ return mcpConfigSnippet(npmPackageSpec(requiredVersion(version)), undefined, 0);
53
+ }
54
+ /**
55
+ * Same argv as init `precompactHookJson` (`notify compaction --data`).
56
+ * Cursor Directory Hooks are Copy, not an installed plugin script.
57
+ */
58
+ export function cursorListingHookCommand(version) {
59
+ return pathFreeCli(`notify compaction --data ${cliDataArg(LISTING_DEFAULT_DATA_DIR)}`, npmPackageSpec(requiredVersion(version)));
60
+ }
61
+ export function cursorListingHooksJson(version) {
62
+ return JSON.stringify({
63
+ version: 1,
64
+ hooks: {
65
+ preCompact: [{ command: cursorListingHookCommand(version) }],
66
+ },
67
+ }, null, 2);
68
+ }
69
+ export function cursorListingSetup() {
70
+ if (silentEmbeddingProvider() !== null) {
71
+ throw new Error("listing MCP JSON assumes semantic search is off by default");
72
+ }
73
+ return [
74
+ `${NODE_REQUIREMENT_LINE} No Facthouse account.`,
75
+ "",
76
+ `1. Click Add to Cursor on the MCP server, then on the rule. Restart. Settings → Tools & MCP should show Facthouse connected. The store is ${LISTING_DEFAULT_DATA_DIR} — no init.`,
77
+ `2. Optional — copy Agent transcripts automatically: ${INIT_PROMPTS.copyRecipe} Kind cursor. ${HOMEPAGE}`,
78
+ `3. Optional — before compact: copy the Hooks JSON into ~/.cursor/hooks.json (we do not install it). --data is ${LISTING_DEFAULT_DATA_DIR} so it matches the MCP default. Hooks do not see mcp.json env.`,
79
+ ].join("\n");
80
+ }
81
+ export function cursorDirectoryListing(version) {
82
+ const pin = requiredVersion(version);
83
+ return {
84
+ origin: CURSOR_DIRECTORY_ORIGIN,
85
+ title: PRODUCT_NAME,
86
+ homepage: HOMEPAGE,
87
+ repository: `https://github.com/${GITHUB_REPO}`,
88
+ description: cursorListingDescription(),
89
+ mcpJson: cursorListingMcpJson(pin),
90
+ setup: cursorListingSetup(),
91
+ rules: CURSOR_RULES_BODY,
92
+ hooks: cursorListingHooksJson(pin),
93
+ };
94
+ }
95
+ export function formatCursorDirectoryListing(listing = cursorDirectoryListing()) {
96
+ return [
97
+ `# Cursor Directory — paste these fields`,
98
+ `# Live: ${listing.origin}`,
99
+ `# Do not add a repo-root .mcp.json.`,
100
+ `# Other listings: node dist/cli/listings.js`,
101
+ ``,
102
+ `## Title`,
103
+ listing.title,
104
+ ``,
105
+ `## Description`,
106
+ listing.description,
107
+ ``,
108
+ `## Homepage`,
109
+ listing.homepage,
110
+ ``,
111
+ `## Repository`,
112
+ listing.repository,
113
+ ``,
114
+ `## MCP JSON`,
115
+ listing.mcpJson,
116
+ ``,
117
+ `## Setup`,
118
+ listing.setup,
119
+ ``,
120
+ `## Rules`,
121
+ listing.rules,
122
+ ``,
123
+ `## Hooks`,
124
+ listing.hooks,
125
+ ``,
126
+ ].join("\n");
127
+ }
128
+ function isMainModule() {
129
+ const entry = process.argv[1];
130
+ if (!entry)
131
+ return false;
132
+ try {
133
+ return (path.normalize(fileURLToPath(import.meta.url)) ===
134
+ path.normalize(path.resolve(entry)));
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ }
140
+ if (isMainModule()) {
141
+ process.stdout.write(formatCursorDirectoryListing());
142
+ }
143
+ //# sourceMappingURL=cursor-listing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-listing.js","sourceRoot":"","sources":["../../src/cli/cursor-listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,UAAU,EACV,cAAc,EACd,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,yFAAyF;AACzF,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,8BAA8B;;;+EAG6C,CAAC;AAqBhF,SAAS,eAAe,CAAC,OAAgB;IACvC,MAAM,QAAQ,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC;IAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,CACL,GAAG,MAAM,mIAAmI;QAC5I,0DAA0D,qBAAqB,GAAG;QAClF,wCAAwC,wBAAwB,IAA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E,EAAE,CAAC;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * TTY remaining-time from recent model-chunk samples. Skips do not sample.
3
+ */
4
+ export declare class ChunkEta {
5
+ private readonly durations;
6
+ private readonly lines;
7
+ noteModelChunk(durationMs: number, lineCount: number): void;
8
+ /** Same estimator; units are facts in an embed batch, not extract lines. */
9
+ noteBatch(durationMs: number, factCount: number): void;
10
+ reset(): void;
11
+ /** Remaining milliseconds, or null until MIN_SAMPLES model chunks. */
12
+ etaMs(linesLeft: number): number | null;
13
+ }
14
+ export declare function formatEta(ms: number): string;
15
+ //# sourceMappingURL=eta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eta.d.ts","sourceRoot":"","sources":["../../src/cli/eta.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAU3D,4EAA4E;IAC5E,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAItD,KAAK,IAAI,IAAI;IAKb,sEAAsE;IACtE,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CASxC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAK5C"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * TTY remaining-time from recent model-chunk samples. Skips do not sample.
3
+ */
4
+ const WINDOW = 8;
5
+ const MIN_SAMPLES = 3;
6
+ export class ChunkEta {
7
+ durations = [];
8
+ lines = [];
9
+ noteModelChunk(durationMs, lineCount) {
10
+ if (!(durationMs > 0) || !(lineCount > 0))
11
+ return;
12
+ this.durations.push(durationMs);
13
+ this.lines.push(lineCount);
14
+ if (this.durations.length > WINDOW) {
15
+ this.durations.shift();
16
+ this.lines.shift();
17
+ }
18
+ }
19
+ /** Same estimator; units are facts in an embed batch, not extract lines. */
20
+ noteBatch(durationMs, factCount) {
21
+ this.noteModelChunk(durationMs, factCount);
22
+ }
23
+ reset() {
24
+ this.durations.length = 0;
25
+ this.lines.length = 0;
26
+ }
27
+ /** Remaining milliseconds, or null until MIN_SAMPLES model chunks. */
28
+ etaMs(linesLeft) {
29
+ if (this.durations.length < MIN_SAMPLES || linesLeft <= 0)
30
+ return null;
31
+ const meanMs = this.durations.reduce((a, b) => a + b, 0) / this.durations.length;
32
+ const meanLines = this.lines.reduce((a, b) => a + b, 0) / this.lines.length;
33
+ if (!(meanLines > 0))
34
+ return null;
35
+ return Math.round((linesLeft / meanLines) * meanMs);
36
+ }
37
+ }
38
+ export function formatEta(ms) {
39
+ const totalSec = Math.max(1, Math.round(ms / 1000));
40
+ if (totalSec < 60)
41
+ return `${totalSec}s`;
42
+ const min = Math.round(totalSec / 60);
43
+ return `${min}m`;
44
+ }
45
+ //# sourceMappingURL=eta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eta.js","sourceRoot":"","sources":["../../src/cli/eta.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,OAAO,QAAQ;IACF,SAAS,GAAa,EAAE,CAAC;IACzB,KAAK,GAAa,EAAE,CAAC;IAEtC,cAAc,CAAC,UAAkB,EAAE,SAAiB;QAClD,IAAI,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC;YAAE,OAAO;QAClD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC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C,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;IACpD,IAAI,QAAQ,GAAG,EAAE;QAAE,OAAO,GAAG,QAAQ,GAAG,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;IACtC,OAAO,GAAG,GAAG,GAAG,CAAC;AACnB,CAAC"}
@@ -5,6 +5,7 @@
5
5
  * server. Copy fills D only (no model). Extract and integrate spend model
6
6
  * calls.
7
7
  */
8
+ import type { HistoricSelection } from "../intelligence/historic-selection.js";
8
9
  import { type InitIo } from "./init-wizard.js";
9
10
  export declare function shouldOfferInitBackfill(opts: {
10
11
  ttyWalk: boolean;
@@ -31,22 +32,43 @@ export type HistoricExtractChoice = {
31
32
  kind: "retry";
32
33
  };
33
34
  export declare function parseHistoricExtract(raw: string): HistoricExtractChoice;
35
+ export declare function historicChoiceToken(choice: HistoricExtractChoice): string | null;
34
36
  export interface InitBackfillConsolidateOpts {
35
37
  /** null = every remaining line; a number = oldest n. */
36
38
  extractLimit: number | null;
37
39
  /** When set, older lines are marked examined without a model call. */
38
40
  extractSince?: Date;
41
+ progressTotal?: number;
42
+ abort?: AbortSignal;
43
+ }
44
+ export interface InitBackfillConsolidateResult {
45
+ factsIntegrated: number;
46
+ eventsRemaining: number;
47
+ skipped?: boolean;
48
+ skipReason?: string;
49
+ extractionDegraded?: boolean;
50
+ prefixCommitted?: boolean;
51
+ examinedThrough?: number;
52
+ aborted?: boolean;
53
+ embedding?: {
54
+ error?: string;
55
+ };
56
+ }
57
+ export interface InitBackfillResult {
58
+ aborted: boolean;
39
59
  }
40
60
  export interface InitBackfillDeps {
41
61
  copy: (dataDir: string) => Promise<{
42
62
  events_inserted: number;
43
63
  }>;
44
64
  unextracted: (dataDir: string) => Promise<number>;
45
- consolidate: (dataDir: string, opts: InitBackfillConsolidateOpts) => Promise<{
46
- factsIntegrated: number;
47
- eventsRemaining: number;
48
- } | undefined>;
65
+ selection: (dataDir: string, choice: Exclude<HistoricExtractChoice, {
66
+ kind: "skip" | "retry";
67
+ }>) => Promise<HistoricSelection>;
68
+ consolidate: (dataDir: string, opts: InitBackfillConsolidateOpts) => Promise<InitBackfillConsolidateResult | undefined>;
49
69
  providerIsHeuristic: boolean;
70
+ hasCursor?: boolean;
71
+ abort?: AbortSignal;
50
72
  }
51
- export declare function offerInitBackfill(io: InitIo, dataDir: string, deps: InitBackfillDeps): Promise<void>;
73
+ export declare function offerInitBackfill(io: InitIo, dataDir: string, deps: InitBackfillDeps): Promise<InitBackfillResult>;
52
74
  //# sourceMappingURL=init-backfill.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-backfill.d.ts","sourceRoot":"","sources":["../../src/cli/init-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEtD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAIV;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,aAAa,EAAE,OAAO,CAAC;IACvB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,OAAO,CAEV;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB,wBAAgB,oBA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