@chendpoc/pi-memory 0.2.0 → 0.2.2

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 (55) hide show
  1. package/README.md +352 -63
  2. package/assets/pi-memory-logo.png +0 -0
  3. package/dist/config/index.d.ts +1 -0
  4. package/dist/config/index.d.ts.map +1 -1
  5. package/dist/config/index.js +1 -0
  6. package/dist/config/index.js.map +1 -1
  7. package/dist/config/preflight.d.ts +8 -0
  8. package/dist/config/preflight.d.ts.map +1 -0
  9. package/dist/config/preflight.js +22 -0
  10. package/dist/config/preflight.js.map +1 -0
  11. package/dist/constants/env.d.ts +3 -0
  12. package/dist/constants/env.d.ts.map +1 -1
  13. package/dist/constants/env.js +3 -0
  14. package/dist/constants/env.js.map +1 -1
  15. package/dist/constants/preflight.d.ts +7 -0
  16. package/dist/constants/preflight.d.ts.map +1 -1
  17. package/dist/constants/preflight.js +7 -0
  18. package/dist/constants/preflight.js.map +1 -1
  19. package/dist/constants/timing.d.ts +2 -0
  20. package/dist/constants/timing.d.ts.map +1 -1
  21. package/dist/constants/timing.js +2 -0
  22. package/dist/constants/timing.js.map +1 -1
  23. package/dist/pi-extension.d.ts.map +1 -1
  24. package/dist/pi-extension.js +21 -2
  25. package/dist/pi-extension.js.map +1 -1
  26. package/dist/preflight/episodic.d.ts +7 -1
  27. package/dist/preflight/episodic.d.ts.map +1 -1
  28. package/dist/preflight/episodic.js +20 -4
  29. package/dist/preflight/episodic.js.map +1 -1
  30. package/dist/preflight/intentCache.d.ts +13 -0
  31. package/dist/preflight/intentCache.d.ts.map +1 -0
  32. package/dist/preflight/intentCache.js +37 -0
  33. package/dist/preflight/intentCache.js.map +1 -0
  34. package/dist/preflight/queryIntent.d.ts +14 -5
  35. package/dist/preflight/queryIntent.d.ts.map +1 -1
  36. package/dist/preflight/queryIntent.js +27 -11
  37. package/dist/preflight/queryIntent.js.map +1 -1
  38. package/dist/sidecar/warmup.d.ts +6 -0
  39. package/dist/sidecar/warmup.d.ts.map +1 -0
  40. package/dist/sidecar/warmup.js +39 -0
  41. package/dist/sidecar/warmup.js.map +1 -0
  42. package/doc/README-zh.md +394 -0
  43. package/doc/ROADMAP-zh.md +52 -0
  44. package/doc/ROADMAP.md +52 -0
  45. package/package.json +5 -1
  46. package/src/config/index.ts +1 -0
  47. package/src/config/preflight.ts +34 -0
  48. package/src/constants/env.ts +3 -0
  49. package/src/constants/preflight.ts +9 -0
  50. package/src/constants/timing.ts +2 -0
  51. package/src/pi-extension.ts +22 -2
  52. package/src/preflight/episodic.ts +28 -4
  53. package/src/preflight/intentCache.ts +44 -0
  54. package/src/preflight/queryIntent.ts +46 -12
  55. package/src/sidecar/warmup.ts +50 -0
package/README.md CHANGED
@@ -1,105 +1,394 @@
1
- # pi-memory
1
+ <p align="center">
2
+ <img src="./assets/pi-memory-logo.png" alt="pi-memory logo" width="720" />
3
+ </p>
2
4
 
3
- Cross-session episodic memory for the [Pi coding agent](https://pi.dev): **MEMORY.md** as ground truth, a JSONL Sidecar for vector retrieval, and Preflight injection before each user turn.
5
+ # @chendpoc/pi-memory
4
6
 
5
- ## Architecture
7
+ <p align="center">
8
+ <a href="README.md">English</a> |
9
+ <a href="doc/README-zh.md">简体中文</a>
10
+ </p>
6
11
 
7
- | Layer | Role |
8
- |-------|------|
9
- | **Ground Truth** | `MEMORY.md` + `auto-*.md` overflow files |
10
- | **Vector Index** | `memory.vec.sqlite` (derived; cosine scan + MMR; default top-3, min relevance 0.4) |
11
- | **Sidecar** | Separate Node process over UDS JSONL (`query`, `reindex`, `ping`) |
12
- | **Preflight** | QueryIntent → Sidecar → Fallback to MEMORY.md → silent empty inject |
12
+ Cross-session episodic memory for the [Pi coding agent](https://pi.dev).
13
13
 
14
- ### Write paths
14
+ `pi-memory` gives Pi a local, auditable memory layer across sessions. It keeps durable facts in **`MEMORY.md` as the source of truth**, derives a vector index in `memory.vec.sqlite`, and injects relevant private context through Preflight before the main model answers.
15
15
 
16
- 1. **`/remember`** sync user-authored append
17
- 2. **Compaction** — dual-purpose summary → `appendFromCompaction` (Compact Delta for subagents)
18
- 3. **Consolidate** — OR trigger (overflow ≥12 / 7 days / daily 03:00 cron)
16
+ ## 🧠 What It Does
19
17
 
20
- **Diagnostics:** **`/memory-status`** in session, or **`pi-memory status`** on the CLI.
18
+ Pi already has compaction for long sessions. That solves "this conversation is too long"; it does not solve "a new session forgot my preferences, project conventions, prior decisions, and unresolved todos."
21
19
 
22
- **Shutdown Queue** — `session_shutdown` appends metadata to `.memory_shutdown_queue.jsonl`; **`pi-memory maintenance`** (or `drain-shutdown-queue`) ingests missed facts offline.
20
+ `pi-memory` fills that gap:
23
21
 
24
- ### Data directory
22
+ ```text
23
+ durable facts -> MEMORY.md -> derived vector index -> per-turn Preflight recall
24
+ ```
25
25
 
26
- All memory artifacts share one root directory (the **memory agent dir**):
26
+ It provides:
27
27
 
28
- | File | Purpose |
29
- |------|---------|
30
- | `MEMORY.md` | Ground truth |
31
- | `auto-*.md` | Overflow entries |
32
- | `memory.vec.sqlite` | Vector index (derived) |
33
- | `memory.sock` | Sidecar UDS |
28
+ - ✍️ **Explicit memory** through `/remember`.
29
+ - 🔁 **Automatic durable fact export** from Pi compaction.
30
+ - 📥 **Shutdown queue recovery** for short or missed sessions.
31
+ - 🔦 **Per-turn private recall** before the main model runs.
32
+ - 📄 **Human-editable storage** in Markdown, with vector search as a rebuildable index.
33
+ - 🔌 **Local UDS sidecar** for vector retrieval and reindexing, without opening an HTTP port.
34
+ - ⏳ **Daemon-friendly maintenance**: shutdown enqueues metadata, while consolidation and queue draining can run offline.
34
35
 
35
- Resolution order (extension and CLI):
36
+ ## 📦 Installation
36
37
 
37
- 1. `--agent-dir` / `PI_MEMORY_AGENT_DIR` — explicit override
38
- 2. Default — `~/.pi/pi-memory-data` (no env required)
38
+ Requirements:
39
39
 
40
- ### MEMORY.md format
40
+ - Node.js `>=24 <25`
41
+ - pnpm
42
+ - Pi extension runtime packages supplied by Pi
41
43
 
42
- Canonical scaffold (`templates/MEMORY.md.example`):
44
+ Install from Pi:
43
45
 
44
- - Title `# Memory` + HTML comment describing entry format
45
- - Four sections: **Preferences**, **Conventions**, **Findings**, **Todos**
46
- - Entries: `- [user] note <!-- id:... user ts:... -->` (via `/remember`) or `- note <!-- id:... ts:... -->`
47
- - 150-line cap; overflow spills to `auto-*.md`
46
+ ```bash
47
+ pi install npm:@chendpoc/pi-memory
48
+ ```
48
49
 
49
- **Initialization** (never overwrites a non-empty file):
50
+ For local development from this repository:
50
51
 
51
- 1. `pnpm install` → `postinstall` seeds `MEMORY.md` in the memory agent dir
52
- 2. First Pi session → `MemoryStore.ensureInitialized()` on `session_start`
53
- 3. Manual: `pi-memory init`
52
+ ```bash
53
+ pnpm install
54
+ pnpm build
55
+ pnpm typecheck
56
+ pnpm test
57
+ ```
54
58
 
55
- ## Setup
59
+ Enable the extension through Pi's extension loading mechanism. This package declares:
60
+
61
+ ```json
62
+ {
63
+ "pi": {
64
+ "extensions": ["./src/pi-extension.ts"]
65
+ }
66
+ }
67
+ ```
56
68
 
57
- 1. Install dependencies and build:
69
+ ### 🌱 Memory workspace (automatic)
70
+
71
+ You usually **do not need to run `pi-memory init` manually**. The same bootstrap (`initializeMemoryWorkspace`) runs automatically and **never overwrites a non-empty `MEMORY.md`**:
72
+
73
+ | When | What happens |
74
+ | --- | --- |
75
+ | **`pnpm install`** | `postinstall` runs `pi-memory init` (or a pre-build fallback) |
76
+ | **First Pi session** | `session_start` → `MemoryStore.ensureInitialized()` |
77
+ | **Manual (optional)** | `pi-memory init` |
78
+
79
+ Run `pi-memory init` explicitly only when:
80
+
81
+ - You set **`PI_MEMORY_AGENT_DIR`** after install (postinstall may have seeded the default path).
82
+ - Install scripts were skipped (`--ignore-scripts` or corporate policy).
83
+ - You want to bootstrap before opening Pi, or verify setup with `pi-memory status`.
58
84
 
59
85
  ```bash
60
- pnpm install
61
- pnpm build
86
+ pi-memory init # optional; see above
87
+ ```
88
+
89
+ ## ✨ Why Choose `pi-memory`
90
+
91
+ ### 🔄 Agent Before / After
92
+
93
+ | Situation | Without `pi-memory` | With `pi-memory` |
94
+ | --- | --- | --- |
95
+ | New session asks "continue the plan from last time" | Agent has to ask for context or guess from the current repo. | Preflight recalls matching `MEMORY.md` facts and injects private reference context. |
96
+ | User says "remember that this repo uses Vitest" | The fact may stay only in the current session summary. | `/remember` writes a `[user]` entry that consolidate must preserve. |
97
+ | Long session compacts | Compaction helps continue that session but does not create durable cross-session facts. | One dual-purpose compact summary keeps session context and exports durable facts. |
98
+ | Subagent is spawned | It may over-recall or duplicate the parent session's memory writes. | Subagents get Memory Cap only and write Compact Delta facts. |
99
+ | Vector sidecar is down | A hard dependency would break the turn. | Preflight silently falls back to Markdown or injects nothing; the model still runs. |
100
+ | Memory grows | A file can become noisy and unbounded. | 150-line `MEMORY.md` cap, `auto-*.md` overflow, consolidate merge/dedupe. |
101
+
102
+ ### 🌟 Key Advantages
103
+
104
+ - 📓 **Markdown Ground Truth**: `MEMORY.md` and `auto-*.md` can be opened, reviewed, edited, grepped, copied, or versioned.
105
+ - 🏗️ **Derived index, not hidden state**: `memory.vec.sqlite` can be deleted and rebuilt from Markdown.
106
+ - 🔎 **Preflight recall**: Memory is injected before the main model answers instead of hoping the model calls a search tool.
107
+ - ⏱️ **Hot-path budget**: Default Preflight budget is **800ms**, with QueryIntent, sidecar query, and fallback all bounded.
108
+ - 🔒 **Protected user notes**: `/remember` writes `[user]` entries that consolidate must not remove or rewrite.
109
+ - 🔗 **UDS, not HTTP**: the agent talks to the sidecar over `node:net` Unix domain sockets with JSONL frames, so there is no local HTTP server or port to secure.
110
+ - 🏭 **Sidecar process isolation**: embedding, vector scan, MMR, stats, and reindex run in a spawned Node process, while writes stay owned by `MemoryStore`.
111
+ - 💤 **Daemon-safe writes**: `session_shutdown` only appends metadata; heavier consolidation and shutdown-queue draining are intended for `pi-memory maintenance` or background scheduling.
112
+ - 👥 **Subagent policy**: root sessions get Memory Cap + Episodic Preflight; subagents get Memory Cap only by default.
113
+ - ☂️ **Graceful fallback**: if sidecar recall is empty, timed out, or unavailable, the turn still runs.
114
+
115
+ ### ⚙️ Runtime Choices
116
+
117
+ | Choice | Why it matters |
118
+ | --- | --- |
119
+ | `MEMORY.md` as Ground Truth | Durable memory remains inspectable and editable instead of becoming opaque database state. |
120
+ | UDS JSONL over `node:net` | Local IPC stays private to the machine, avoids HTTP ports, and keeps request/response framing simple. |
121
+ | Spawned sidecar process | Vector query/reindex work is isolated from the Pi extension process; failures degrade to Markdown fallback. |
122
+ | Offline `maintenance` job | Consolidation and shutdown-queue draining can run outside the interactive agent turn. |
123
+ | Bounded Preflight | QueryIntent, sidecar query, cache, and fallback all share a tight latency budget. |
124
+
125
+ ### ⚖️ Comparison
126
+
127
+ `pi-memory` is not trying to be every memory system. The value is a specific Pi-native loop: Markdown ground truth, Preflight injection, sidecar retrieval, compaction export, and offline maintenance.
128
+
129
+ | System | Strength | Difference From `@chendpoc/pi-memory` |
130
+ | --- | --- | --- |
131
+ | Cursor Rules / OpenCode `AGENTS.md` | Static project instructions, predictable injection. | Mostly user-authored rules; no automatic durable fact extraction or per-turn episodic Preflight. |
132
+ | Claude Code Auto Memory | Agent can write local memory files. | File-based memory, but no sidecar vector recall or Pi compact/shutdown integration. |
133
+ | `pi-hermes-memory` | Rich Pi package with FTS5, failure memory, correction learning, security scanning. | More automated and feature-heavy; no `<private_memory>` Preflight loop or sidecar-derived vector index. |
134
+ | OpenClaw memory-core | Mature file + index design, dreaming, hybrid search, local embeddings. | Broader memory platform; `pi-memory` is narrower and Pi-extension focused. |
135
+ | Mem0 / Zep | Managed memory APIs with hybrid search, graph, temporal modeling. | Stronger retrieval infrastructure, but external service/database oriented and not Markdown-ground-truth first. |
136
+ | Letta | Context engineering with git-backed memory repos and sleep-time compute. | Powerful for autonomous memory management; heavier mental model than Pi's extension lifecycle. |
137
+ | Cognee | Knowledge engine with graph/vector/relational stores and many retrieval modes. | Better for knowledge graphs; overkill for lightweight coding-agent preferences and conventions. |
138
+
139
+ Where other systems are stronger:
140
+
141
+ - `pi-hermes-memory`: failure memory, correction detector, tool quirks, secret scanning.
142
+ - OpenClaw: dreaming stages, memory wiki, hybrid FTS/vector search, local embedding providers.
143
+ - Zep/Cognee: temporal graph reasoning and multi-hop graph retrieval.
144
+ - Mem0: hosted multi-tenant memory API.
145
+ - Letta: autonomous context repositories and sleep-time memory work.
146
+
147
+ ## ⚙️ How It Works
148
+
149
+ ### 🏗️ Architecture
150
+
151
+ ```text
152
+ Pi extension process
153
+ |- session_start
154
+ | |- initialize MEMORY.md
155
+ | |- start/warm sidecar
156
+ | |- reindex derived vector index
157
+ | `- preload Memory Cap
158
+ |
159
+ |- before_agent_start / context
160
+ | `- Preflight recall -> <private_memory> injection
161
+ |
162
+ |- /remember
163
+ | `- append [user] Memory Entry
164
+ |
165
+ |- session_before_compact / session_compact
166
+ | `- dual-purpose summary -> Memory Export ingest
167
+ |
168
+ |- session_shutdown
169
+ | `- append shutdown metadata only
170
+ |
171
+ `- consolidate scheduler
172
+ `- merge/dedupe -> rewrite Ground Truth -> reindex
173
+
174
+ Sidecar process over UDS JSONL (`node:net`, no HTTP port)
175
+ |- ping
176
+ |- stats
177
+ |- query: embed -> cosine scan -> MMR
178
+ `- reindex: upsert chunks into memory.vec.sqlite
62
179
  ```
63
180
 
64
- 2. Enable as a Pi extension (see `package.json` → `pi.extensions`).
181
+ ### 🔎 Read Path
182
+
183
+ Root session:
184
+
185
+ ```text
186
+ Memory Cap from Ground Truth
187
+ + Episodic Preflight for the current user message
188
+ -> merged <private_memory>
189
+ ```
190
+
191
+ Subagent session:
192
+
193
+ ```text
194
+ Memory Cap only
195
+ -> no episodic QueryIntent / sidecar query by default
196
+ ```
197
+
198
+ Fallback chain:
199
+
200
+ ```text
201
+ Sidecar results
202
+ -> if empty/error/timeout: MEMORY.md fallback
203
+ -> if empty: no injection
204
+ ```
205
+
206
+ ### ✍️ Write Paths
207
+
208
+ | Path | Trigger | LLM? | Blocking? | Purpose |
209
+ | --- | --- | --- | --- | --- |
210
+ | `/remember` | User command | No | Yes | Explicit durable note |
211
+ | Compaction | `session_before_compact` + `session_compact` | One summary call | Summary blocks; ingest is background | Continue current session and export durable facts |
212
+ | Shutdown Queue | `session_shutdown` + `pi-memory maintenance` | Only offline, when no compaction summary exists | No during shutdown | Recover facts from short or missed sessions |
213
+ | Consolidate | overflow >= 12, 7 days, or daily cron | Optional | Offline/background | Dedupe, merge, prune obsolete todos |
214
+
215
+ ## 💾 Data And Memory Format
216
+
217
+ All artifacts live under one memory agent directory.
218
+
219
+ Resolution order:
220
+
221
+ 1. `--agent-dir` CLI flag
222
+ 2. `PI_MEMORY_AGENT_DIR`
223
+ 3. default `~/.pi/pi-memory-data`
224
+
225
+ | File | Role |
226
+ | --- | --- |
227
+ | `MEMORY.md` | Ground Truth file |
228
+ | `auto-*.md` | Overflow files after the 150-line cap |
229
+ | `.memory_gc` | Last consolidate timestamp |
230
+ | `.memory_compactions.json` | Compaction idempotency state |
231
+ | `.memory_shutdown_queue.jsonl` | Append-only shutdown metadata |
232
+ | `.memory_shutdown_processed.json` | Drain idempotency state |
233
+ | `memory.vec.sqlite` | Derived Vector Index |
234
+ | `memory.sock` | Sidecar Unix domain socket |
65
235
 
66
- 3. Optional: copy [`.env.example`](./.env.example) to `~/.pi/agent/pi-memory.env` and configure embedder / helper LLM.
236
+ Canonical scaffold: [`templates/MEMORY.md.example`](./templates/MEMORY.md.example)
67
237
 
68
- ## Environment
238
+ ```markdown
239
+ # Memory
69
240
 
70
- | Variable | Purpose |
71
- |----------|---------|
72
- | `PI_MEMORY_AGENT_DIR` | Memory data root (see [Data directory](#data-directory)) |
73
- | `PI_MEMORY_EMBEDDER` | `hash` (default, offline) \| `ollama` \| `openai` |
74
- | `PI_MEMORY_HELPER_MODEL` | Helper LLM for QueryIntent + consolidate |
75
- | `PI_MEMORY_PREFLIGHT_BUDGET_MS` | Preflight shared budget (default 800ms: ~240 intent + ~560 sidecar) |
76
- | `PI_MEMORY_REINDEX_DEBOUNCE_MS` | Debounced reindex after writes |
77
- | `PI_MEMORY_DEBUG` | `1` enables debug stderr logs (preflight timings) |
241
+ ## Preferences
78
242
 
79
- See [`.env.example`](./.env.example) for full list.
243
+ ## Conventions
80
244
 
81
- ## CLI
245
+ ## Findings
246
+
247
+ ## Todos
248
+ ```
249
+
250
+ Entries are single Markdown bullets:
251
+
252
+ ```markdown
253
+ - [user] Prefer pnpm over npm <!-- id:abc123 user ts:2026-07-04T09:00:00.000+08:00 -->
254
+ - Project tests use Vitest <!-- id:def456 ts:2026-07-04T09:05:00.000+08:00 -->
255
+ ```
256
+
257
+ Rules:
258
+
259
+ - `/remember` writes `[user]` entries.
260
+ - Consolidate must not remove or rewrite `[user]` entries.
261
+ - `MEMORY.md` is capped at 150 lines.
262
+ - Overflow entries spill to `auto-*.md`, with a pointer in `MEMORY.md`.
263
+ - Vector chunks are derived from entries; by default long entries split beyond `PI_MEMORY_CHUNK_MAX_CHARS=512`.
264
+
265
+ ## 🎛️ Configuration
266
+
267
+ Optional env file locations are loaded in this order:
268
+
269
+ 1. `PI_MEMORY_ENV_FILE`
270
+ 2. project `.env`
271
+ 3. project `.env.local`
272
+ 4. `~/.pi/agent/pi-memory.env`
273
+
274
+ Common variables:
275
+
276
+ | Variable | Default | Purpose |
277
+ | --- | --- | --- |
278
+ | `PI_MEMORY_AGENT_DIR` | `~/.pi/pi-memory-data` | Memory data root |
279
+ | `PI_MEMORY_EMBEDDER` | `hash` | `hash`, `ollama`, or `openai` |
280
+ | `PI_MEMORY_HELPER_MODEL` | `deepseek/deepseek-v4-flash` | Helper model spec for QueryIntent and consolidate |
281
+ | `PI_MEMORY_PREFLIGHT_BUDGET_MS` | `800` | Shared Preflight budget, clamped to 250-1500ms |
282
+ | `PI_MEMORY_INTENT_RETRIES` | `0` | Helper LLM retries after the first attempt |
283
+ | `PI_MEMORY_WARM_SIDECAR` | `1` | Warm sidecar at `session_start` |
284
+ | `PI_MEMORY_INTENT_CACHE` | `1` | Cache QueryIntent per session |
285
+ | `PI_MEMORY_REINDEX_DEBOUNCE_MS` | `500` | Debounce sidecar reindex after writes |
286
+ | `PI_MEMORY_TOP_K` | `3` | Vector recall result count |
287
+ | `PI_MEMORY_MMR_LAMBDA` | `0.8` | MMR relevance/diversity balance |
288
+ | `PI_MEMORY_MIN_RELEVANCE` | `0.4` | Minimum cosine similarity |
289
+ | `PI_MEMORY_CHUNK_MAX_CHARS` | `512` | Split long entries for indexing; `0` disables |
290
+ | `PI_MEMORY_DEBUG` | unset | `1` prints debug timing logs |
291
+
292
+ See [`.env.example`](./.env.example) for the full list.
293
+
294
+ ### 🛰️ Embedders
295
+
296
+ | Embedder | Use When | Notes |
297
+ | --- | --- | --- |
298
+ | `hash` | Zero-config local development | Offline, deterministic, lower semantic quality |
299
+ | `ollama` | Local semantic embeddings | Uses `PI_MEMORY_OLLAMA_BASE_URL` and `PI_MEMORY_OLLAMA_EMBED_MODEL` |
300
+ | `openai` | Higher-quality cloud embeddings | Requires `PI_MEMORY_OPENAI_API_KEY` or `OPENAI_API_KEY` |
301
+
302
+ The Vector Index stores embedding provider, model, and dimension metadata. When they change, old chunks are cleared and rebuilt.
303
+
304
+ ## ⌨️ Commands
305
+
306
+ Inside Pi:
307
+
308
+ ```text
309
+ /remember [section] <content>
310
+ /memory-status [refresh|expand|collapse|hide]
311
+ ```
312
+
313
+ CLI:
82
314
 
83
315
  ```bash
84
- pi-memory init
85
316
  pi-memory status
86
317
  pi-memory maintenance --cron --verbose
87
318
  pi-memory consolidate --force --verbose
88
319
  pi-memory drain-shutdown-queue --verbose
320
+ pi-memory init # optional — usually automatic after install + first session
321
+ ```
322
+
323
+ `maintenance` is the recommended scheduler entrypoint:
324
+
325
+ ```text
326
+ consolidate -> drain-shutdown-queue
89
327
  ```
90
328
 
91
- `maintenance` runs **consolidate → drain-shutdown-queue** in one cron window (recommended for OS schedulers).
92
- `status` prints MEMORY.md, sidecar, and vector index diagnostics (colored on TTY stderr).
93
- Set `PI_MEMORY_DEBUG=1` for preflight timing logs during agent sessions.
329
+ Scheduler templates:
330
+
331
+ - [`templates/com.pi.memory.consolidate.plist.example`](./templates/com.pi.memory.consolidate.plist.example)
332
+ - [`templates/crontab.example`](./templates/crontab.example)
333
+ - [`templates/consolidate.cmd.example`](./templates/consolidate.cmd.example)
334
+ - [`templates/schtasks.example.txt`](./templates/schtasks.example.txt)
335
+
336
+ ## 🩺 Diagnostics
337
+
338
+ Use `/memory-status` or `pi-memory status` to inspect:
339
+
340
+ - memory agent directory
341
+ - `MEMORY.md` line count
342
+ - entry count
343
+ - overflow count
344
+ - last consolidate timestamp
345
+ - sidecar socket status
346
+ - vector index generation and chunk count
347
+ - configured embedder
348
+ - index embedder mismatch
349
+
350
+ Use `PI_MEMORY_DEBUG=1` to log Preflight timings:
351
+
352
+ ```json
353
+ {
354
+ "phase": "preflight",
355
+ "event": "recall",
356
+ "intent_ms": 0,
357
+ "intent_skipped": true,
358
+ "intent_cache_hit": false,
359
+ "sidecar_ms": 42,
360
+ "cache_hit": true,
361
+ "total_ms": 45,
362
+ "fallback": false,
363
+ "results": 3
364
+ }
365
+ ```
366
+
367
+ ## 🚫 Non-Goals
368
+
369
+ - Replacing Pi compaction.
370
+ - Replacing session search; use a dedicated session-search extension for old conversations.
371
+ - Maintaining a graph database inside this package.
372
+ - Making the sidecar authoritative.
373
+ - Storing full chat transcripts as memory.
374
+ - Adding multi-second reflection to every user turn.
375
+
376
+ ## 🛠️ Development
377
+
378
+ ```bash
379
+ pnpm typecheck
380
+ pnpm test
381
+ pnpm build
382
+ ```
94
383
 
95
- Templates: [`templates/`](./templates/) (launchd, crontab, schtasks).
384
+ The sidecar IPC test opens a Unix domain socket. If it fails with `listen EPERM` inside a restricted sandbox, run the test in a normal local shell.
96
385
 
97
- ## Docs
386
+ ## 📚 Docs
98
387
 
99
- - [sidecar-local-memory-design.md](./sidecar-local-memory-design.md) — full design
100
- - [kocoro-memory-pi-agent-guide.md](./kocoro-memory-pi-agent-guide.md) — Kocoro → Pi translation
101
- - [UBIQUITOUS_LANGUAGE.md](./UBIQUITOUS_LANGUAGE.md) domain glossary
388
+ - [Chinese README](./doc/README-zh.md)
389
+ - [Roadmap](./doc/ROADMAP.md)
390
+ - [UBIQUITOUS_LANGUAGE.md](./UBIQUITOUS_LANGUAGE.md) - domain glossary
102
391
 
103
- ## License
392
+ ## 📜 License
104
393
 
105
394
  MIT
Binary file
@@ -2,6 +2,7 @@ export { KNOWN_EMBED_DIMS, readPiMemoryEnv, resolveEmbedDim, type EmbedderProvid
2
2
  export { readRetrievalConfig, type RetrievalConfig } from "./retrieval.js";
3
3
  export { readChunkingConfig, type ChunkingConfig } from "./chunking.js";
4
4
  export { resolvePreflightBudget, type PreflightBudget } from "./preflightBudget.js";
5
+ export { readPreflightRuntimeConfig, type PreflightRuntimeConfig } from "./preflight.js";
5
6
  export { resolveAgentDirFromEnv, resolveMemoryAgentDir, type ResolveMemoryAgentDirOptions } from "./agentDir.js";
6
7
  export { loadEnv } from "./loadEnv.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -2,6 +2,7 @@ export { KNOWN_EMBED_DIMS, readPiMemoryEnv, resolveEmbedDim } from "./env.js";
2
2
  export { readRetrievalConfig } from "./retrieval.js";
3
3
  export { readChunkingConfig } from "./chunking.js";
4
4
  export { resolvePreflightBudget } from "./preflightBudget.js";
5
+ export { readPreflightRuntimeConfig } from "./preflight.js";
5
6
  export { resolveAgentDirFromEnv, resolveMemoryAgentDir } from "./agentDir.js";
6
7
  export { loadEnv } from "./loadEnv.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAA2C,MAAM,UAAU,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAuB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAwB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAqC,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAA2C,MAAM,UAAU,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAuB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAwB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAA+B,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAqC,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type PreflightRuntimeConfig = {
2
+ intentRetries: number;
3
+ warmSidecar: boolean;
4
+ intentCache: boolean;
5
+ };
6
+ /** Runtime toggles for preflight latency optimizations. */
7
+ export declare function readPreflightRuntimeConfig(env?: NodeJS.ProcessEnv): PreflightRuntimeConfig;
8
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/config/preflight.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AASF,2DAA2D;AAC3D,wBAAgB,0BAA0B,CACxC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,sBAAsB,CASxB"}
@@ -0,0 +1,22 @@
1
+ import { ENV_KEYS } from "../constants/env.js";
2
+ import { DEFAULT_INTENT_CACHE_ENABLED, DEFAULT_INTENT_RETRIES, DEFAULT_WARM_SIDECAR_ENABLED, MAX_INTENT_RETRIES, } from "../constants/preflight.js";
3
+ function parseOnOff(value, defaultOn) {
4
+ if (value === undefined || value.trim() === "")
5
+ return defaultOn;
6
+ const normalized = value.trim().toLowerCase();
7
+ if (normalized === "0" || normalized === "false" || normalized === "no")
8
+ return false;
9
+ return true;
10
+ }
11
+ /** Runtime toggles for preflight latency optimizations. */
12
+ export function readPreflightRuntimeConfig(env = process.env) {
13
+ const retries = Number.parseInt(env[ENV_KEYS.INTENT_RETRIES] ?? String(DEFAULT_INTENT_RETRIES), 10);
14
+ return {
15
+ intentRetries: Number.isFinite(retries)
16
+ ? Math.min(Math.max(0, retries), MAX_INTENT_RETRIES)
17
+ : DEFAULT_INTENT_RETRIES,
18
+ warmSidecar: parseOnOff(env[ENV_KEYS.WARM_SIDECAR], DEFAULT_WARM_SIDECAR_ENABLED),
19
+ intentCache: parseOnOff(env[ENV_KEYS.INTENT_CACHE], DEFAULT_INTENT_CACHE_ENABLED),
20
+ };
21
+ }
22
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/config/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AAQnC,SAAS,UAAU,CAAC,KAAyB,EAAE,SAAkB;IAC/D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IACjE,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,OAAO,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,0BAA0B,CACxC,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,CAAC,CAAC;IACpG,OAAO;QACL,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,CAAC;YACpD,CAAC,CAAC,sBAAsB;QAC1B,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,4BAA4B,CAAC;QACjF,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,4BAA4B,CAAC;KAClF,CAAC;AACJ,CAAC"}
@@ -24,6 +24,9 @@ export declare const ENV_KEYS: {
24
24
  readonly MMR_LAMBDA: "PI_MEMORY_MMR_LAMBDA";
25
25
  readonly MIN_RELEVANCE: "PI_MEMORY_MIN_RELEVANCE";
26
26
  readonly CHUNK_MAX_CHARS: "PI_MEMORY_CHUNK_MAX_CHARS";
27
+ readonly INTENT_RETRIES: "PI_MEMORY_INTENT_RETRIES";
28
+ readonly WARM_SIDECAR: "PI_MEMORY_WARM_SIDECAR";
29
+ readonly INTENT_CACHE: "PI_MEMORY_INTENT_CACHE";
27
30
  readonly AGENT_DIR: "PI_MEMORY_AGENT_DIR";
28
31
  readonly ENV_FILE: "PI_MEMORY_ENV_FILE";
29
32
  readonly DEBUG: "PI_MEMORY_DEBUG";
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/constants/env.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM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D,eAAO,MAAM,yBAAyB,+BAAuD,CAAC;AAE9F,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnD,CAAC;AAEF,eAAO,MAAM,sBAAsB,MAAM,CAAC"}
@@ -23,6 +23,9 @@ export const ENV_KEYS = {
23
23
  MMR_LAMBDA: "PI_MEMORY_MMR_LAMBDA",
24
24
  MIN_RELEVANCE: "PI_MEMORY_MIN_RELEVANCE",
25
25
  CHUNK_MAX_CHARS: "PI_MEMORY_CHUNK_MAX_CHARS",
26
+ INTENT_RETRIES: "PI_MEMORY_INTENT_RETRIES",
27
+ WARM_SIDECAR: "PI_MEMORY_WARM_SIDECAR",
28
+ INTENT_CACHE: "PI_MEMORY_INTENT_CACHE",
26
29
  AGENT_DIR: "PI_MEMORY_AGENT_DIR",
27
30
  ENV_FILE: "PI_MEMORY_ENV_FILE",
28
31
  DEBUG: "PI_MEMORY_DEBUG",
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/constants/env.ts"],"names":[],"mappings":"AAEA,sCAAsC;AACtC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,QAAQ,EAAE,oBAAoB;IAC9B,SAAS,EAAE,qBAAqB;IAChC,cAAc,EAAE,0BAA0B;IAC1C,kBAAkB,EAAE,8BAA8B;IAClD,eAAe,EAAE,2BAA2B;IAC5C,kBAAkB,EAAE,8BAA8B;IAClD,mBAAmB,EAAE,+BAA+B;IACpD,gBAAgB,EAAE,4BAA4B;IAC9C,YAAY,EAAE,wBAAwB;IACtC,cAAc,EAAE,0BAA0B;IAC1C,sBAAsB,EAAE,kCAAkC;IAC1D,mBAAmB,EAAE,+BAA+B;IACpD,qBAAqB,EAAE,iCAAiC;IACxD,eAAe,EAAE,2BAA2B;IAC5C,mBAAmB,EAAE,+BAA+B;IACpD,oDAAoD;IACpD,oBAAoB,EAAE,g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G,IAAI,CAAC;AAE/C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,wBAAwB,EAAE,IAAI;IAC9B,wBAAwB,EAAE,IAAI;IAC9B,kBAAkB,EAAE,GAAG;IACvB,mBAAmB,EAAE,IAAI;IACzB,YAAY,EAAE,GAAG;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC"}
@@ -7,4 +7,11 @@ export declare const PRIVATE_MEMORY_CLOSE = "</private_memory>";
7
7
  export declare const MEMORY_CUE_RE: RegExp;
8
8
  export declare const PREFLIGHT_SKIP_MIN_LENGTH = 12;
9
9
  export declare const PREFLIGHT_EXTRACT_MIN_LENGTH = 24;
10
+ /** Helper LLM retries after the first attempt (0 = single try). */
11
+ export declare const DEFAULT_INTENT_RETRIES = 0;
12
+ export declare const MAX_INTENT_RETRIES = 3;
13
+ /** Sidecar warm start + intent LRU defaults. */
14
+ export declare const DEFAULT_WARM_SIDECAR_ENABLED = true;
15
+ export declare const DEFAULT_INTENT_CACHE_ENABLED = true;
16
+ export declare const INTENT_CACHE_MAX_ENTRIES = 128;
10
17
  //# sourceMappingURL=preflight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/constants/preflight.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,4BAA4B,QAAW,CAAC;AAErD,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,mBAAmB,qBAA4B,CAAC;AAC7D,eAAO,MAAM,oBAAoB,sBAA6B,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,aAAa,QACiF,CAAC;AAE5G,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/constants/preflight.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,4BAA4B,QAAW,CAAC;AAErD,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,mBAAmB,qBAA4B,CAAC;AAC7D,eAAO,MAAM,oBAAoB,sBAA6B,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,aAAa,QACiF,CAAC;AAE5G,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,wBAAwB,MAAM,CAAC"}
@@ -7,4 +7,11 @@ export const PRIVATE_MEMORY_CLOSE = `</${PRIVATE_MEMORY_TAG}>`;
7
7
  export const MEMORY_CUE_RE = /(?:\b(recent|recently|last time|continue|previous|remember|recall|before|earlier)\b|之前|上次|继续|记得|回忆|刚才)/i;
8
8
  export const PREFLIGHT_SKIP_MIN_LENGTH = 12;
9
9
  export const PREFLIGHT_EXTRACT_MIN_LENGTH = 24;
10
+ /** Helper LLM retries after the first attempt (0 = single try). */
11
+ export const DEFAULT_INTENT_RETRIES = 0;
12
+ export const MAX_INTENT_RETRIES = 3;
13
+ /** Sidecar warm start + intent LRU defaults. */
14
+ export const DEFAULT_WARM_SIDECAR_ENABLED = true;
15
+ export const DEFAULT_INTENT_CACHE_ENABLED = true;
16
+ export const INTENT_CACHE_MAX_ENTRIES = 128;
10
17
  //# sourceMappingURL=preflight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/constants/preflight.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,kBAAkB,GAAG,CAAC;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,kBAAkB,GAAG,CAAC;AAE/D,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GACxB,yGAAyG,CAAC;AAE5G,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/constants/preflight.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,kBAAkB,GAAG,CAAC;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,kBAAkB,GAAG,CAAC;AAE/D,qEAAqE;AACrE,MAAM,CAAC,MAAM,aAAa,GACxB,yGAAyG,CAAC;AAE5G,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,gDAAgD;AAChD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC"}
@@ -29,6 +29,8 @@ export declare const SIDECAR_FORCE_KILL_DELAY_MS = 5000;
29
29
  export declare const SIDECAR_PING_TIMEOUT_MS = 1000;
30
30
  export declare const SIDECAR_QUERY_TIMEOUT_MS = 3000;
31
31
  export declare const SIDECAR_REINDEX_TIMEOUT_MS = 10000;
32
+ /** Warm start dummy query (session_start; not counted against Preflight budget). */
33
+ export declare const SIDECAR_WARMUP_QUERY_TIMEOUT_MS = 500;
32
34
  /** proper-lockfile on MEMORY.md. */
33
35
  export declare const MEMORY_LOCK_RETRIES = 5;
34
36
  export declare const MEMORY_LOCK_MIN_TIMEOUT_MS = 100;
@@ -1 +1 @@
1
- {"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../src/constants/timing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,QAAsB,CAAC;AAE9C,2BAA2B;AAC3B,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAC9C,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,8EAA8E;AAC9E,eAAO,MAAM,gCAAgC,MAAM,CAAC;AAEpD,kDAAkD;AAClD,eAAO,MAAM,4BAA4B,MAA8B,CAAC;AAExE,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,qDAAqD;AACrD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,uDAAuD;AACvD,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AAErD,sEAAsE;AACtE,eAAO,MAAM,qCAAqC,QAAa,CAAC;AAEhE,2CAA2C;AAC3C,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,iCAAiC;AACjC,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAC9C,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAEjD,mCAAmC;AACnC,eAAO,MAAM,uBA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eAAO,MAAM,0BAA0B,QAAS,CAAC;AACjD,oFAAoF;AACpF,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD,oCAAoC;AACpC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,0BAA0B,MAAM,CAAC"}
@@ -29,6 +29,8 @@ export const SIDECAR_FORCE_KILL_DELAY_MS = 5_000;
29
29
  export const SIDECAR_PING_TIMEOUT_MS = 1_000;
30
30
  export const SIDECAR_QUERY_TIMEOUT_MS = 3_000;
31
31
  export const SIDECAR_REINDEX_TIMEOUT_MS = 10_000;
32
+ /** Warm start dummy query (session_start; not counted against Preflight budget). */
33
+ export const SIDECAR_WARMUP_QUERY_TIMEOUT_MS = 500;
32
34
  /** proper-lockfile on MEMORY.md. */
33
35
  export const MEMORY_LOCK_RETRIES = 5;
34
36
  export const MEMORY_LOCK_MIN_TIMEOUT_MS = 100;