memorix 1.2.6 → 1.2.7

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 (45) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +6 -3
  3. package/README.zh-CN.md +5 -2
  4. package/dist/cli/index.js +954 -72
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/cli/memcode.js +0 -0
  7. package/dist/index.js +632 -27
  8. package/dist/index.js.map +1 -1
  9. package/dist/maintenance-runner.js +39 -1
  10. package/dist/maintenance-runner.js.map +1 -1
  11. package/dist/memcode-runtime/CHANGELOG.md +12 -0
  12. package/dist/sdk.d.ts +1 -1
  13. package/dist/sdk.js +632 -27
  14. package/dist/sdk.js.map +1 -1
  15. package/dist/types.d.ts +38 -1
  16. package/dist/types.js.map +1 -1
  17. package/docs/1.2.7-CONTEXT-CONTINUITY.md +68 -0
  18. package/docs/API_REFERENCE.md +6 -2
  19. package/docs/dev-log/progress.txt +23 -0
  20. package/docs/hooks-architecture.md +2 -1
  21. package/package.json +1 -1
  22. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  23. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  24. package/plugins/copilot/memorix/plugin.json +1 -1
  25. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  26. package/plugins/omp/memorix/extensions/memorix.js +17 -0
  27. package/plugins/omp/memorix/package.json +1 -1
  28. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  29. package/plugins/pi/memorix/extensions/memorix.js +17 -0
  30. package/plugins/pi/memorix/package.json +1 -1
  31. package/src/cli/capability-map.ts +1 -0
  32. package/src/cli/command-guide.ts +10 -0
  33. package/src/cli/commands/checkpoint.ts +144 -0
  34. package/src/cli/index.ts +3 -1
  35. package/src/codegraph/auto-context.ts +51 -5
  36. package/src/hooks/handler.ts +103 -11
  37. package/src/hooks/normalizer.ts +85 -1
  38. package/src/hooks/types.ts +16 -0
  39. package/src/knowledge/workset.ts +43 -2
  40. package/src/memory/compaction.ts +165 -0
  41. package/src/server/tool-profile.ts +1 -0
  42. package/src/server.ts +94 -0
  43. package/src/store/compaction-checkpoint-store.ts +397 -0
  44. package/src/store/sqlite-db.ts +41 -0
  45. package/src/types.ts +46 -0
@@ -528,6 +528,34 @@ CREATE TABLE IF NOT EXISTS maintenance_targets (
528
528
  );
529
529
  `;
530
530
 
531
+ // ── 1.2.7 Cross-Agent Compaction Checkpoints ───────────────────────
532
+
533
+ const CREATE_COMPACTION_CHECKPOINTS_TABLE = `
534
+ CREATE TABLE IF NOT EXISTS compaction_checkpoints (
535
+ id TEXT PRIMARY KEY,
536
+ project_id TEXT NOT NULL,
537
+ session_id TEXT NOT NULL,
538
+ agent TEXT NOT NULL,
539
+ phase TEXT NOT NULL,
540
+ capture_kind TEXT NOT NULL,
541
+ reason TEXT NOT NULL DEFAULT 'unknown',
542
+ source_event TEXT NOT NULL,
543
+ source_key TEXT NOT NULL,
544
+ summary TEXT,
545
+ tokens_before INTEGER,
546
+ first_kept_entry_id TEXT,
547
+ details_json TEXT NOT NULL DEFAULT '{}',
548
+ transcript_available INTEGER NOT NULL DEFAULT 0,
549
+ status TEXT NOT NULL DEFAULT 'active',
550
+ pre_captured_at TEXT NOT NULL,
551
+ completed_at TEXT,
552
+ delivered_at TEXT,
553
+ delivery_count INTEGER NOT NULL DEFAULT 0,
554
+ created_at TEXT NOT NULL,
555
+ updated_at TEXT NOT NULL
556
+ );
557
+ `;
558
+
531
559
  const CREATE_INDEXES = `
532
560
  CREATE INDEX IF NOT EXISTS idx_observations_projectId ON observations(projectId);
533
561
  CREATE INDEX IF NOT EXISTS idx_observations_topicKey ON observations(projectId, topicKey);
@@ -574,6 +602,9 @@ CREATE INDEX IF NOT EXISTS idx_knowledge_workflow_runs_project_workflow ON knowl
574
602
  CREATE INDEX IF NOT EXISTS idx_maintenance_jobs_ready ON maintenance_jobs(status, run_after);
575
603
  CREATE INDEX IF NOT EXISTS idx_maintenance_jobs_project ON maintenance_jobs(project_id, status, run_after);
576
604
  CREATE INDEX IF NOT EXISTS idx_maintenance_targets_updated ON maintenance_targets(updated_at);
605
+ CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_project_recent ON compaction_checkpoints(project_id, status, completed_at DESC, pre_captured_at DESC);
606
+ CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_session_pending ON compaction_checkpoints(project_id, session_id, agent, phase, status, pre_captured_at DESC);
607
+ CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_source ON compaction_checkpoints(project_id, source_key);
577
608
  CREATE UNIQUE INDEX IF NOT EXISTS idx_maintenance_jobs_active_dedupe
578
609
  ON maintenance_jobs(project_id, kind, dedupe_key)
579
610
  WHERE status IN ('pending', 'running', 'retry');
@@ -665,6 +696,15 @@ const SCHEMA_MIGRATIONS: SchemaMigration[] = [
665
696
  db.exec('CREATE INDEX IF NOT EXISTS idx_knowledge_workflow_runs_project_workflow ON knowledge_workflow_runs(projectId, workflowId, startedAt DESC)');
666
697
  },
667
698
  },
699
+ {
700
+ id: '1.2.7-compaction-checkpoints',
701
+ apply: (db) => {
702
+ db.exec(CREATE_COMPACTION_CHECKPOINTS_TABLE);
703
+ db.exec('CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_project_recent ON compaction_checkpoints(project_id, status, completed_at DESC, pre_captured_at DESC)');
704
+ db.exec('CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_session_pending ON compaction_checkpoints(project_id, session_id, agent, phase, status, pre_captured_at DESC)');
705
+ db.exec('CREATE INDEX IF NOT EXISTS idx_compaction_checkpoints_source ON compaction_checkpoints(project_id, source_key)');
706
+ },
707
+ },
668
708
  ];
669
709
 
670
710
  function applySchemaMigrations(db: any): void {
@@ -732,6 +772,7 @@ export function getDatabase(dataDir: string): any {
732
772
  db.exec(CREATE_OBSERVATION_CODE_REFS_TABLE);
733
773
  db.exec(CREATE_MAINTENANCE_JOBS_TABLE);
734
774
  db.exec(CREATE_MAINTENANCE_TARGETS_TABLE);
775
+ db.exec(CREATE_COMPACTION_CHECKPOINTS_TABLE);
735
776
 
736
777
  // Phase 3a migration: add sourceSnapshot + updatedAt to mini_skills
737
778
  // Idempotent — ALTER TABLE ADD COLUMN throws if column already exists
package/src/types.ts CHANGED
@@ -189,6 +189,52 @@ export interface Session {
189
189
  agent?: string;
190
190
  }
191
191
 
192
+ // ============================================================
193
+ // Cross-Agent Compaction Continuity
194
+ // ============================================================
195
+
196
+ /** Whether a checkpoint is still waiting for host compaction or has completed. */
197
+ export type CompactionCheckpointPhase = 'pre' | 'complete';
198
+
199
+ /** Native compaction reason when the host exposes it. */
200
+ export type CompactionReason = 'manual' | 'auto' | 'unknown';
201
+
202
+ /** How much first-party compaction evidence the host actually exposed. */
203
+ export type CompactionCaptureKind = 'preflight' | 'lifecycle' | 'native-summary';
204
+
205
+ /** Lifecycle state for a persisted compaction checkpoint. */
206
+ export type CompactionCheckpointStatus = 'active' | 'archived';
207
+
208
+ /**
209
+ * A source-aware record of one host-native context compaction.
210
+ *
211
+ * This is intentionally not an Observation: a host summary is evidence for
212
+ * continuation, not automatically durable project truth.
213
+ */
214
+ export interface CompactionCheckpoint {
215
+ id: string;
216
+ projectId: string;
217
+ sessionId: string;
218
+ agent: string;
219
+ phase: CompactionCheckpointPhase;
220
+ captureKind: CompactionCaptureKind;
221
+ reason: CompactionReason;
222
+ sourceEvent: string;
223
+ sourceKey: string;
224
+ summary?: string;
225
+ tokensBefore?: number;
226
+ firstKeptEntryId?: string;
227
+ details?: Record<string, unknown>;
228
+ transcriptAvailable: boolean;
229
+ status: CompactionCheckpointStatus;
230
+ preCapturedAt: string;
231
+ completedAt?: string;
232
+ deliveredAt?: string;
233
+ deliveryCount: number;
234
+ createdAt: string;
235
+ updatedAt: string;
236
+ }
237
+
192
238
  // ============================================================
193
239
  // Compact Engine (adopted from claude-mem 3-layer workflow)
194
240
  // ============================================================