bilmem 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -17,12 +17,17 @@ Its purpose is to help an agent:
17
17
 
18
18
  ### Core Epistemic Philosophy
19
19
 
20
- Bilmem differs fundamentally from repository graphs, vector databases, and memory dumps:
21
- - Traditional repository tools primarily ask: **"What is related to X?"**
22
- - Traditional memory systems primarily ask: **"What did we previously store about X?"**
23
- - **Bilmem asks:**
20
+ Bilmem differs fundamentally from repository graphs, search engines, and memory dumps:
24
21
 
25
- > **"Do I know enough to act, what do I know does not apply, what am I missing, and what is the cheapest next step to resolve the uncertainty?"**
22
+ ```text
23
+ Repository graph: "What is connected to this code?"
24
+ Search / RAG: "What information looks relevant?"
25
+ Memory dump: "What did we store before?"
26
+
27
+ Bilmem lookup: "What do we already know?"
28
+ Bilmem resolve: "Do we know this specific thing well enough to act?"
29
+ Bilmem preflight: "What must we know before starting this work?"
30
+ ```
26
31
 
27
32
  Bilmem is a lightweight **epistemic runtime**.
28
33
 
@@ -34,6 +39,44 @@ Bilmem is a lightweight **epistemic runtime**.
34
39
 
35
40
  > **Prefer the smallest action likely to resolve the uncertainty.**
36
41
 
42
+ > **Before substantial work, understand constraints, lessons, and blocking unknowns.**
43
+
44
+ ### The Bilmem Product Loop
45
+
46
+ ```text
47
+ BEFORE WORK
48
+ preflight
49
+ ↓
50
+ expose constraints
51
+ surface past lessons
52
+ identify unknowns
53
+ identify stale knowledge
54
+ ask high-value questions
55
+
56
+ DURING WORK
57
+ resolve
58
+ ↓
59
+ reuse knowledge
60
+ reject wrong-context knowledge
61
+ avoid repeated investigation
62
+ find cheapest next evidence
63
+
64
+ AFTER WORK
65
+ learn
66
+ ↓
67
+ observations
68
+ outcomes
69
+ reconciliation
70
+ refinement
71
+
72
+ OVER TIME
73
+ compact + stats
74
+ ↓
75
+ healthier knowledge
76
+ less duplication
77
+ measurable reuse
78
+ ```
79
+
37
80
  ## Architecture Overview
38
81
 
39
82
  ```text
@@ -173,6 +216,9 @@ Inside `.bilmem/`, the source-of-truth is stored in **append-friendly JSONL** fi
173
216
  ## CLI Commands
174
217
 
175
218
  ```bash
219
+ # Primary Preflight Operation: What must be known before starting work?
220
+ bilmem preflight "Add OAuth login with Google" [--deep]
221
+
176
222
  # Primary Epistemic Operation: Do I know enough to act, what is missing, cheapest next action?
177
223
  bilmem resolve "How are sessions renewed?" -p server-session -n stateless-jwt
178
224
 
@@ -219,11 +265,98 @@ bilmem restore snapshot.yml
219
265
  # Compact knowledge base (merge duplicates, clean stale observations)
220
266
  bilmem compact [--dry-run]
221
267
 
268
+ # Local-first statistics & knowledge health
269
+ bilmem stats
270
+
222
271
  # Status summary & metrics
223
272
  bilmem status
224
273
  ```
225
274
 
226
- ### Primary Operation: `bilmem resolve`
275
+ ### Preflight Before Substantial Work: `bilmem preflight`
276
+
277
+ Before starting substantial implementation work, `bilmem preflight` surfaces existing constraints, applicable past lessons, past failures, stale knowledge, and blocking unknowns.
278
+
279
+ ```bash
280
+ # Analyze existing knowledge relative to a proposed goal
281
+ bilmem preflight "Add OAuth login with Google"
282
+
283
+ # Pass contextual positive and negative cues
284
+ bilmem preflight "Add OAuth login with Google" -p server-session -n stateless-jwt
285
+
286
+ # Deep mode: targeted git diff & file staleness verification
287
+ bilmem preflight "Add OAuth login with Google" --deep
288
+
289
+ # Structured JSON output
290
+ bilmem preflight "Add OAuth login with Google" --json
291
+ ```
292
+
293
+ Structured output:
294
+ ```yaml
295
+ goal: Add OAuth login with Google
296
+ readiness: NEEDS_CLARIFICATION
297
+
298
+ known:
299
+ - id: auth.session.server
300
+ statement: Sessions are server-side in Redis.
301
+ confidence: high
302
+ - id: auth.user.service
303
+ statement: User creation goes through UserService.
304
+ confidence: high
305
+
306
+ constraints:
307
+ - id: auth.storage.boundary
308
+ statement: Auth routes must not access storage directly.
309
+ - id: auth.token.browser
310
+ statement: Authentication tokens must not be persisted in browser storage.
311
+
312
+ lessons:
313
+ - id: auth.refresh.validation
314
+ statement: Validate callback credentials before session creation.
315
+
316
+ past_failures:
317
+ - id: auth.session.duplicate-write
318
+ statement: Concurrent session creation previously caused duplicate writes.
319
+
320
+ unknowns:
321
+ - id: auth.oauth.account-linking
322
+ question: Should OAuth identities be linked to existing accounts?
323
+ blocking: true
324
+ - id: auth.oauth.scopes
325
+ question: Which OAuth scopes are required?
326
+ blocking: false
327
+
328
+ stale:
329
+ - id: auth.provider.abstraction
330
+ reason: Supporting source changed after last validation.
331
+
332
+ questions:
333
+ - question: What should happen when the Google email already belongs to an existing account?
334
+ reason: Existing account-linking semantics are unknown.
335
+
336
+ likely_domains:
337
+ - authentication
338
+ - session
339
+ - user-identity
340
+
341
+ next:
342
+ - type: ASK_USER
343
+ target: auth.oauth.account-linking
344
+ reason: Resolve account-linking semantics before implementation.
345
+ - type: REVALIDATE
346
+ target: auth.provider.abstraction
347
+ reason: Supporting source changed after last validation.
348
+ ```
349
+
350
+ ### Readiness Model
351
+
352
+ Readiness is categorical, never a vanity percentage score:
353
+ - **`READY`**: Bilmem found validated knowledge, no unresolved contradictions, no blocking unknowns, and no critical stale dependencies.
354
+ - **`NEEDS_CLARIFICATION`**: One or more important product/behavior decisions or blocking unknowns are unresolved and require human clarification (`ASK_USER`).
355
+ - **`NEEDS_REVALIDATION`**: Critical relevant knowledge exists, but its supporting code or evidence was modified.
356
+ - **`CONFLICTED`**: Multiple applicable credible knowledge units disagree and contextual specialization cannot resolve the conflict.
357
+ - **`INSUFFICIENT_KNOWLEDGE`**: Not enough evidence or knowledge units exist locally to evaluate preflight.
358
+
359
+ ### Primary Epistemic Operation: `bilmem resolve`
227
360
 
228
361
  Unlike search or lookup, `resolve` executes an epistemic evaluation:
229
362
 
@@ -291,14 +424,15 @@ bilmem mcp
291
424
  ```
292
425
 
293
426
  ### Exposed MCP Tools:
294
- 1. `bilmem_resolve`: Primary epistemic operation. Determines if enough is known to answer or act, what contextually does not apply, what is missing, and the cheapest next step to resolve uncertainty.
295
- 2. `bilmem_lookup`: Query knowledge with positive/negative context cues. Returns compact, highly applicable knowledge units without flooding agent context.
296
- 3. `bilmem_observe`: Record an observation with preserved provenance.
297
- 4. `bilmem_learn`: Learn from task trajectories or explicit user corrections.
298
- 5. `bilmem_explain`: Inspectable explanation of why an item is known (supports `--history`).
299
- 6. `bilmem_unknown`: Query or record first-class unknowns with checked paths.
300
- 7. `bilmem_scan`: Trigger a repository scan.
301
- 8. `bilmem_stats`: Inspect local-first statistics, knowledge health, and effectiveness metrics (read-only).
427
+ 1. `bilmem_preflight`: Preflight knowledge analysis before substantial work. Surface constraints, lessons, failures, stale knowledge, and blocking unknowns in compact format.
428
+ 2. `bilmem_resolve`: Primary epistemic operation. Determines if enough is known to answer or act, what contextually does not apply, what is missing, and the cheapest next step to resolve uncertainty.
429
+ 3. `bilmem_lookup`: Query knowledge with positive/negative context cues. Returns compact, highly applicable knowledge units without flooding agent context.
430
+ 4. `bilmem_observe`: Record an observation with preserved provenance.
431
+ 5. `bilmem_learn`: Learn from task trajectories or explicit user corrections.
432
+ 6. `bilmem_explain`: Inspectable explanation of why an item is known (supports `--history`).
433
+ 7. `bilmem_unknown`: Query or record first-class unknowns with checked paths.
434
+ 8. `bilmem_scan`: Trigger a repository scan.
435
+ 9. `bilmem_stats`: Inspect local-first statistics, knowledge health, and effectiveness metrics (read-only).
302
436
 
303
437
  ---
304
438
 
@@ -314,6 +448,7 @@ bilmem install
314
448
  bilmem install cursor
315
449
  bilmem install claude
316
450
  bilmem install codex
451
+ bilmem install antigravity
317
452
  bilmem install gemini
318
453
 
319
454
  # Non-interactive / CI automation
@@ -321,13 +456,13 @@ bilmem install --detected --yes
321
456
  bilmem install --all
322
457
 
323
458
  # Dry-run preview
324
- bilmem install cursor --dry-run
459
+ bilmem install antigravity --dry-run
325
460
 
326
461
  # Global vs Project scope (defaults to project-local)
327
- bilmem install cursor --global
462
+ bilmem install antigravity --global
328
463
 
329
464
  # Safe uninstallation (preserves other servers and user rules)
330
- bilmem uninstall cursor
465
+ bilmem uninstall antigravity
331
466
 
332
467
  # Health diagnostics & automated repair
333
468
  bilmem doctor
@@ -335,9 +470,10 @@ bilmem doctor --fix
335
470
  ```
336
471
 
337
472
  ### Safe, Non-Destructive Editing
338
- - **JSON Configuration**: Safely parses existing agent configs (`.cursor/mcp.json`, `.claude/mcp.json`, etc.), injects the `bilmem` MCP server under `mcpServers`, preserves all existing third-party servers and settings, and writes atomically.
339
- - **Agent Instructions**: Installs a token-efficient instruction block bounded by `<!-- bilmem:start -->` and `<!-- bilmem:end -->` into `.cursorrules`, `CLAUDE.md`, `CODEX.md`, or `GEMINI.md` without overwriting custom user guidelines.
340
- - **Ownership Tracking**: Maintains metadata in `.bilmem/integrations.json` so `bilmem uninstall` cleanly removes only Bilmem-owned blocks and registrations.
473
+ - **JSON Configuration**: Safely parses existing agent configs (`.agents/mcp_config.json`, `.cursor/mcp.json`, `.claude/mcp.json`, etc.), injects the `bilmem` MCP server under `mcpServers`, preserves all existing third-party servers and settings, and writes atomically.
474
+ - **Antigravity Skills**: For Antigravity, installs a first-class on-demand skill into `.agents/skills/bilmem/SKILL.md` (project) or `~/.gemini/config/skills/bilmem/SKILL.md` (global) with YAML frontmatter for progressive disclosure and tool runbook guidance.
475
+ - **Agent Instructions & Rules**: Installs a token-efficient instruction block bounded by `<!-- bilmem:start -->` and `<!-- bilmem:end -->` into `.agents/rules/bilmem.md`, `.cursorrules`, `CLAUDE.md`, `CODEX.md`, or `GEMINI.md` without overwriting custom user guidelines.
476
+ - **Ownership Tracking**: Maintains metadata in `.bilmem/integrations.json` so `bilmem uninstall` cleanly removes only Bilmem-owned blocks, skills, and registrations.
341
477
 
342
478
  ---
343
479
 
@@ -396,6 +532,13 @@ import { Bilmem } from 'bilmem';
396
532
  const bilmem = new Bilmem();
397
533
  await bilmem.init();
398
534
 
535
+ // Preflight analysis before starting implementation
536
+ const preflight = await bilmem.preflight({
537
+ goal: 'Add OAuth login with Google',
538
+ positive: ['auth', 'server']
539
+ });
540
+ console.log(preflight.readiness); // READY | NEEDS_CLARIFICATION | etc.
541
+
399
542
  // Lookup knowledge with contextual cues
400
543
  const results = await bilmem.lookup({
401
544
  query: 'session renewal',
@@ -1,4 +1,4 @@
1
- import { u as ResolutionState, A as ActionType, O as OutcomeType, m as KnowledgeStatus, l as KnowledgeStage, B as BilmemConfig, K as Knowledge, c as Evidence, o as Observation, U as UnknownRecord, p as OutcomeRecord, I as InvestigationReceipt, d as EvidenceRelation, b as BilmemMetrics, y as RuleSet, x as RuleDefinition, v as RevisionSnapshot, h as KnowledgeDiff } from './types-Nxq5Gzay.js';
1
+ import { Q as ResolutionState, A as ActionType, O as OutcomeType, F as ReadinessStatus, o as KnowledgeStatus, n as KnowledgeStage, B as BilmemConfig, K as Knowledge, e as Evidence, q as Observation, U as UnknownRecord, r as OutcomeRecord, I as InvestigationReceipt, f as EvidenceRelation, d as BilmemMetrics, Y as RuleSet, X as RuleDefinition, V as RevisionSnapshot, j as KnowledgeDiff } from './types-DNlvHsj9.js';
2
2
  import { KnowledgeStoreProvider } from './search/index.js';
3
3
 
4
4
  type JevRejectReason = 'HARD_NEGATIVE' | 'SCOPE_MISMATCH' | 'INSUFFICIENT_CONTEXT' | 'STALE_KNOWLEDGE' | 'CONTEXT_MISMATCH';
@@ -78,6 +78,16 @@ type MetricEvent = {
78
78
  knowledgeId: string;
79
79
  result: OutcomeType;
80
80
  timestamp: number;
81
+ } | {
82
+ type: 'preflight';
83
+ goal: string;
84
+ readiness: ReadinessStatus;
85
+ blockingUnknownsCount: number;
86
+ staleKnowledgeCount: number;
87
+ pastFailuresCount: number;
88
+ questionsCount: number;
89
+ repeatedChecksAvoidedCount: number;
90
+ timestamp: number;
81
91
  };
82
92
  interface EffectivenessRatio {
83
93
  value?: number;
@@ -152,6 +162,19 @@ interface StatsReport {
152
162
  frequentlyMisleading: number;
153
163
  unused: number;
154
164
  };
165
+ preflight?: {
166
+ runs: number;
167
+ ready: number;
168
+ needsClarification: number;
169
+ needsRevalidation: number;
170
+ conflicted: number;
171
+ insufficientKnowledge: number;
172
+ blockingUnknownsFound: number;
173
+ staleKnowledgeFound: number;
174
+ pastFailuresSurfaced: number;
175
+ questionsSuggested: number;
176
+ repeatedChecksAvoided: number;
177
+ };
155
178
  }
156
179
  interface KnowledgeStatsReport {
157
180
  id: string;