synapse-causal-memory 0.2.3 → 0.3.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.
@@ -3,6 +3,7 @@ export interface ServerOptions {
3
3
  readonly port?: number;
4
4
  readonly host?: string;
5
5
  readonly dbPath?: string;
6
+ readonly contextDbPath?: string;
6
7
  }
7
8
  export interface JsonRpcRequest {
8
9
  readonly jsonrpc?: string;
@@ -282,11 +283,288 @@ export declare const CAUSAL_MCP_TOOLS: readonly [{
282
283
  };
283
284
  };
284
285
  };
286
+ }, {
287
+ readonly name: "save_context_checkpoint";
288
+ readonly description: "현재 작업 세션의 핵심 컨텍스트(목표, 완료 단계, 다음 할 일, 핵심 설계 결정, 활성 파일, 아티팩트)를 초경량 스냅샷으로 저장하여 새 채팅창에서도 기억 손실 없이 0ms 복원할 수 있게 합니다.";
289
+ readonly inputSchema: {
290
+ readonly type: "object";
291
+ readonly required: readonly ["title"];
292
+ readonly properties: {
293
+ readonly id: {
294
+ readonly type: "string";
295
+ readonly description: "고유 체크포인트 ID (생략 시 자동 생성)";
296
+ };
297
+ readonly sessionId: {
298
+ readonly type: "string";
299
+ readonly description: "프로젝트 또는 세션 식별자 (예: synapse-kit)";
300
+ };
301
+ readonly title: {
302
+ readonly type: "string";
303
+ readonly description: "현재 컨텍스트 스냅샷 요약 제목";
304
+ };
305
+ readonly goal: {
306
+ readonly type: "string";
307
+ readonly description: "현재 달성 중인 핵심 목표";
308
+ };
309
+ readonly completedSteps: {
310
+ readonly type: "array";
311
+ readonly items: {
312
+ readonly type: "string";
313
+ };
314
+ readonly description: "이번 세션까지 완료된 핵심 작업 목록";
315
+ };
316
+ readonly pendingTasks: {
317
+ readonly type: "array";
318
+ readonly items: {
319
+ readonly type: "string";
320
+ };
321
+ readonly description: "다음 채팅/세션에서 바로 이어서 진행할 할 일 목록";
322
+ };
323
+ readonly keyDecisions: {
324
+ readonly type: "array";
325
+ readonly items: {
326
+ readonly type: "string";
327
+ };
328
+ readonly description: "핵심 설계 결정 및 아키텍처 주의사항";
329
+ };
330
+ readonly activeFiles: {
331
+ readonly type: "array";
332
+ readonly items: {
333
+ readonly type: "string";
334
+ };
335
+ readonly description: "집중 작업 중인 파일 경로 목록";
336
+ };
337
+ readonly artifacts: {
338
+ readonly type: "array";
339
+ readonly items: {
340
+ readonly type: "string";
341
+ };
342
+ readonly description: "관련 아티팩트 또는 마스터 설계 문서 경로 목록";
343
+ };
344
+ readonly cwd: {
345
+ readonly type: "string";
346
+ readonly description: "작업 디렉터리 경로";
347
+ };
348
+ };
349
+ };
350
+ }, {
351
+ readonly name: "load_context_checkpoint";
352
+ readonly description: "저장된 컨텍스트 체크포인트 스냅샷(최신 또는 특정 ID/세션)을 0ms 만에 복원하여 새 채팅창에서 이전 작업을 즉시 이어갑니다.";
353
+ readonly inputSchema: {
354
+ readonly type: "object";
355
+ readonly properties: {
356
+ readonly id: {
357
+ readonly type: "string";
358
+ readonly description: "복원할 체크포인트 ID, 제목 키워드, 또는 'latest' (기본값: 'latest')";
359
+ };
360
+ readonly sessionId: {
361
+ readonly type: "string";
362
+ readonly description: "특정 세션/프로젝트의 최신 스냅샷만 필터링할 경우 지정";
363
+ };
364
+ readonly compact: {
365
+ readonly type: "boolean";
366
+ readonly description: "초소형 JSON 포맷으로 반환할지 여부";
367
+ };
368
+ };
369
+ };
370
+ }, {
371
+ readonly name: "list_context_checkpoints";
372
+ readonly description: "저장된 모든 작업 컨텍스트 스냅샷(Checkpoint) 목록을 최신순으로 조회합니다.";
373
+ readonly inputSchema: {
374
+ readonly type: "object";
375
+ readonly properties: {
376
+ readonly sessionId: {
377
+ readonly type: "string";
378
+ readonly description: "특정 세션/프로젝트 필터";
379
+ };
380
+ readonly limit: {
381
+ readonly type: "number";
382
+ readonly description: "조회할 최대 개수 (기본값: 20)";
383
+ };
384
+ };
385
+ };
386
+ }, {
387
+ readonly name: "time_travel_causal_memory";
388
+ readonly description: "인과율 시계열(Time-Series) 엔진을 통해 시간 감쇠 가중치 계산, 체크포인트 간 변경 diff 분석, 특정 과거 시점으로의 리와인드, 세션 타임라인을 생성합니다.";
389
+ readonly inputSchema: {
390
+ readonly type: "object";
391
+ readonly required: readonly ["action"];
392
+ readonly properties: {
393
+ readonly action: {
394
+ readonly type: "string";
395
+ readonly enum: readonly ["diff", "rewind", "timeline", "decay"];
396
+ readonly description: "수행할 시계열 동작 (diff: 비교, rewind: 되돌리기, timeline: 타임라인, decay: 감쇠 계산)";
397
+ };
398
+ readonly fromId: {
399
+ readonly type: "string";
400
+ readonly description: "비교 기준 시작 체크포인트 ID (diff 전용)";
401
+ };
402
+ readonly toId: {
403
+ readonly type: "string";
404
+ readonly description: "비교 대상 목표 체크포인트 ID (diff 전용)";
405
+ };
406
+ readonly targetId: {
407
+ readonly type: "string";
408
+ readonly description: "리와인드 대상 체크포인트 ID (rewind 전용)";
409
+ };
410
+ readonly limit: {
411
+ readonly type: "number";
412
+ readonly description: "타임라인 조회 개수";
413
+ };
414
+ };
415
+ };
416
+ }, {
417
+ readonly name: "scan_causal_graveyard";
418
+ readonly description: "부정적 기억 / 안티패턴 함정(Graveyard)을 실시간으로 스캔하여 실패를 유발했던 접근법인지 선제 검증하거나, 새로운 실패 가설을 등록합니다.";
419
+ readonly inputSchema: {
420
+ readonly type: "object";
421
+ readonly required: readonly ["action"];
422
+ readonly properties: {
423
+ readonly action: {
424
+ readonly type: "string";
425
+ readonly enum: readonly ["scan", "assert", "list"];
426
+ readonly description: "동작 (scan: 함정 검사, assert: 실패 가설 등록, list: 전체 목록)";
427
+ };
428
+ readonly files: {
429
+ readonly type: "array";
430
+ readonly items: {
431
+ readonly type: "string";
432
+ };
433
+ readonly description: "수정 예정 파일 목록 (scan용)";
434
+ };
435
+ readonly keywords: {
436
+ readonly type: "array";
437
+ readonly items: {
438
+ readonly type: "string";
439
+ };
440
+ readonly description: "의도/접근법 키워드 (scan용)";
441
+ };
442
+ readonly trapPattern: {
443
+ readonly type: "string";
444
+ readonly description: "실패 유발 패턴 이름 (assert용)";
445
+ };
446
+ readonly domain: {
447
+ readonly type: "string";
448
+ readonly description: "도메인 (assert용)";
449
+ };
450
+ readonly reason: {
451
+ readonly type: "string";
452
+ readonly description: "실패 원인 (assert용)";
453
+ };
454
+ readonly safeAlternative: {
455
+ readonly type: "string";
456
+ readonly description: "안전한 대안 (assert용)";
457
+ };
458
+ readonly severity: {
459
+ readonly type: "string";
460
+ readonly enum: readonly ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
461
+ readonly description: "위험도";
462
+ };
463
+ readonly avoidFiles: {
464
+ readonly type: "array";
465
+ readonly items: {
466
+ readonly type: "string";
467
+ };
468
+ readonly description: "금지 파일 패턴";
469
+ };
470
+ };
471
+ };
472
+ }, {
473
+ readonly name: "branch_causal_context";
474
+ readonly description: "작업 맥락을 독립된 브랜치(Mental Fork)로 분기하거나, 검증 후 메인에 병합(Merge)하고, 실패한 실험은 폐기(Abandon)하여 Graveyard에 안티패턴으로 자동 이관합니다.";
475
+ readonly inputSchema: {
476
+ readonly type: "object";
477
+ readonly required: readonly ["action"];
478
+ readonly properties: {
479
+ readonly action: {
480
+ readonly type: "string";
481
+ readonly enum: readonly ["list", "create", "switch", "merge", "abandon"];
482
+ readonly description: "브랜치 동작 (list: 목록, create: 생성, switch: 전환, merge: 병합, abandon: 폐기 및 함정 등록)";
483
+ };
484
+ readonly name: {
485
+ readonly type: "string";
486
+ readonly description: "브랜치 이름";
487
+ };
488
+ readonly fromBranch: {
489
+ readonly type: "string";
490
+ readonly description: "분기 기준 부모 브랜치 (create용)";
491
+ };
492
+ readonly targetBranch: {
493
+ readonly type: "string";
494
+ readonly description: "병합 대상 브랜치 (merge용)";
495
+ };
496
+ readonly failureReason: {
497
+ readonly type: "string";
498
+ readonly description: "폐기 사유 (abandon용)";
499
+ };
500
+ readonly safeAlternative: {
501
+ readonly type: "string";
502
+ readonly description: "안전한 대안 (abandon용)";
503
+ };
504
+ };
505
+ };
506
+ }, {
507
+ readonly name: "predict_blast_radius";
508
+ readonly description: "수정 대상 파일들을 기반으로 인과 그래프의 2~3단계 연쇄 파급 영향(Blast Radius)과 위험도(0~100)를 산출하고, 위반 방지를 위해 관련 불변식들을 사전 페치(prefetch)합니다.";
509
+ readonly inputSchema: {
510
+ readonly type: "object";
511
+ readonly required: readonly ["files"];
512
+ readonly properties: {
513
+ readonly files: {
514
+ readonly type: "array";
515
+ readonly items: {
516
+ readonly type: "string";
517
+ };
518
+ readonly description: "수정 대상 파일 목록";
519
+ };
520
+ readonly maxHops: {
521
+ readonly type: "number";
522
+ readonly description: "최대 파급 전파 단계 (기본값: 3)";
523
+ };
524
+ };
525
+ };
526
+ }, {
527
+ readonly name: "synthesize_git_checkpoint";
528
+ readonly description: "Git 상태 및 diff를 분석하여 작업자의 의도(Goal, Completed Steps, Pending Tasks)를 자동 역합성(Reverse Synthesis)하고 원클릭 체크포인트를 저장합니다.";
529
+ readonly inputSchema: {
530
+ readonly type: "object";
531
+ readonly properties: {
532
+ readonly cwd: {
533
+ readonly type: "string";
534
+ readonly description: "작업 디렉터리 경로";
535
+ };
536
+ readonly title: {
537
+ readonly type: "string";
538
+ readonly description: "사용자 지정 제목 (생략 시 자동 생성)";
539
+ };
540
+ readonly autoCheckpoint: {
541
+ readonly type: "boolean";
542
+ readonly description: "분석 후 체크포인트 즉시 저장 여부 (기본: true)";
543
+ };
544
+ };
545
+ };
546
+ }, {
547
+ readonly name: "sync_obsidian_lens";
548
+ readonly description: "옵시디언(Obsidian) 볼트와 인과율 메모리(규칙, 함정, 스냅샷, 타임라인, 캔버스 다이어그램)를 완벽하게 양방향 동기화(Sync)합니다.";
549
+ readonly inputSchema: {
550
+ readonly type: "object";
551
+ readonly properties: {
552
+ readonly action: {
553
+ readonly type: "string";
554
+ readonly enum: readonly ["export", "import", "sync"];
555
+ readonly description: "동작 (export: 마크다운/캔버스 내보내기, import: 마크다운 읽어오기, sync: 양방향 동기화)";
556
+ };
557
+ readonly vaultPath: {
558
+ readonly type: "string";
559
+ readonly description: "옵시디언 볼트 루트 경로 (생략 시 기본 환경변수/OS 경로 사용)";
560
+ };
561
+ };
562
+ };
285
563
  }];
286
564
  /**
287
565
  * MCP JSON-RPC 2.0 요청 통합 처리기 (HTTP 데몬 및 Stdio 서버 공용)
288
566
  */
289
- export declare function handleMcpJsonRpcRequest(rpc: JsonRpcRequest, store: CausalMemoryStore, dbPath?: string): Promise<Record<string, any> | null>;
567
+ export declare function handleMcpJsonRpcRequest(rpc: JsonRpcRequest, store: CausalMemoryStore, dbPath?: string, contextDbPath?: string): Promise<Record<string, any> | null>;
290
568
  /**
291
569
  * 인과율 메모리 독립 로컬 서버 (Causal Memory HTTP & MCP Daemon)
292
570
  */
@@ -14,6 +14,7 @@ export interface CausalRelation {
14
14
  readonly from: string;
15
15
  readonly to: string;
16
16
  readonly relationType: string;
17
+ readonly relation?: string;
17
18
  }
18
19
  /**
19
20
  * 인과율 규칙(Node) 규격
@@ -28,6 +29,12 @@ export interface CausalRule {
28
29
  readonly actions: readonly string[];
29
30
  readonly context: readonly string[];
30
31
  readonly lastVerified?: string;
32
+ readonly name?: string;
33
+ readonly confidence?: number;
34
+ readonly weight?: number;
35
+ readonly updatedAt?: string;
36
+ readonly description?: string;
37
+ readonly pattern?: string;
31
38
  }
32
39
  /**
33
40
  * 인과율 메모리 데이터베이스 규격
@@ -0,0 +1,96 @@
1
+ import { ContextCheckpointStore, type ContextCheckpoint } from './causal-context';
2
+ import { CausalMemoryStore } from './causal-store';
3
+ /**
4
+ * Git 변경 사항 상세 통계 규격
5
+ */
6
+ export interface GitChangeStats {
7
+ readonly insertions: number;
8
+ readonly deletions: number;
9
+ readonly filesChanged: number;
10
+ }
11
+ /**
12
+ * Git 변경 코드에서 추출된 주요 심볼 메타데이터 규격
13
+ */
14
+ export interface ExtractedCodeSymbols {
15
+ readonly functions: readonly string[];
16
+ readonly classes: readonly string[];
17
+ readonly interfaces: readonly string[];
18
+ readonly types: readonly string[];
19
+ }
20
+ /**
21
+ * 작업 트리의 변경 사항 요약 규격
22
+ */
23
+ export interface GitChangeSummary {
24
+ readonly cwd: string;
25
+ readonly branch?: string;
26
+ readonly commit?: string;
27
+ readonly modifiedFiles: readonly string[];
28
+ readonly addedFiles: readonly string[];
29
+ readonly deletedFiles: readonly string[];
30
+ readonly untrackedFiles: readonly string[];
31
+ readonly allActiveFiles: readonly string[];
32
+ readonly stats: GitChangeStats;
33
+ readonly extractedSymbols: ExtractedCodeSymbols;
34
+ readonly detectedDomains: readonly string[];
35
+ }
36
+ /**
37
+ * 역합성된 의도 및 진행 상태 규격
38
+ */
39
+ export interface SynthesizedIntent {
40
+ readonly title: string;
41
+ readonly goal: string;
42
+ readonly completedSteps: readonly string[];
43
+ readonly pendingTasks: readonly string[];
44
+ readonly keyDecisions: readonly string[];
45
+ readonly activeInvariants: readonly string[];
46
+ readonly suggestedKeywords: readonly string[];
47
+ }
48
+ /**
49
+ * 자동 체크포인트 생성 옵션
50
+ */
51
+ export interface AutoCheckpointOptions {
52
+ readonly title?: string;
53
+ readonly goal?: string;
54
+ readonly extraCompletedSteps?: readonly string[];
55
+ readonly extraPendingTasks?: readonly string[];
56
+ readonly extraKeyDecisions?: readonly string[];
57
+ readonly extraInvariants?: readonly string[];
58
+ readonly customMeta?: Record<string, unknown>;
59
+ readonly autoResonance?: boolean;
60
+ }
61
+ /**
62
+ * Git 커밋 및 diff 기반으로 작업자의 의도와 상태를 역합성하는 인과율 엔진 클래스 (SRP 준수)
63
+ */
64
+ export declare class CausalSynthesizerEngine {
65
+ private readonly contextStore;
66
+ private readonly memoryStore;
67
+ constructor(contextStore?: ContextCheckpointStore, memoryStore?: CausalMemoryStore);
68
+ /**
69
+ * 지정된 작업 디렉터리의 Git 상태와 diff를 분석하여 변경 내역 요약 생성
70
+ */
71
+ inspectGitChanges(cwd?: string): Promise<GitChangeSummary>;
72
+ /**
73
+ * Git 통계 파싱 (git diff --stat)
74
+ */
75
+ private parseGitStats;
76
+ /**
77
+ * git diff로부터 변경된 함수, 클래스, 타입 심볼을 추출
78
+ */
79
+ private extractSymbolsFromDiff;
80
+ /**
81
+ * 파일 경로 기반 도메인 분류
82
+ */
83
+ private detectDomainsFromFiles;
84
+ /**
85
+ * Git 미설치 또는 Git 저장소가 아닌 경우의 폴백 파일시스템 스캔
86
+ */
87
+ private fallbackFilesystemScan;
88
+ /**
89
+ * 변경 사항 분석 결과를 기반으로 작업 의도 및 컨텍스트를 자동 역합성(Reverse Synthesis)
90
+ */
91
+ synthesizeIntent(summary: GitChangeSummary, customTitle?: string): SynthesizedIntent;
92
+ /**
93
+ * 원클릭 자동 체크포인트 생성 (Git diff 분석 ➔ 역합성 ➔ 스냅샷 저장)
94
+ */
95
+ autoCheckpoint(cwd?: string, options?: AutoCheckpointOptions): Promise<ContextCheckpoint>;
96
+ }
@@ -0,0 +1,92 @@
1
+ import { ContextCheckpointStore, type ContextCheckpoint } from './causal-context';
2
+ /**
3
+ * 시계열 이벤트 레코드 규격
4
+ */
5
+ export interface TimelineEvent {
6
+ readonly id: string;
7
+ readonly timestamp: string;
8
+ readonly timestampMs: number;
9
+ readonly type: 'checkpoint' | 'rule_added' | 'rule_updated' | 'branch_merged' | 'trap_recorded';
10
+ readonly sessionId: string;
11
+ readonly title: string;
12
+ readonly summary: string;
13
+ readonly tags: readonly string[];
14
+ readonly checkpointId?: string;
15
+ }
16
+ /**
17
+ * 두 체크포인트 간의 시계열 차분(Diff) 결과 규격
18
+ */
19
+ export interface CheckpointDiffResult {
20
+ readonly fromId?: string;
21
+ readonly toId?: string;
22
+ readonly fromCheckpointId: string;
23
+ readonly toCheckpointId: string;
24
+ readonly fromTimestamp: string;
25
+ readonly toTimestamp: string;
26
+ readonly timeDeltaHours: number;
27
+ readonly newlyCompletedSteps?: readonly string[];
28
+ readonly resolvedPendingTasks?: readonly string[];
29
+ readonly addedModifiedFiles?: readonly string[];
30
+ readonly addedPendingTasks: readonly string[];
31
+ readonly resolvedTasks: readonly string[];
32
+ readonly newCompletedSteps: readonly string[];
33
+ readonly newDecisions: readonly string[];
34
+ readonly modifiedFilesDelta: {
35
+ readonly added: readonly string[];
36
+ readonly removed: readonly string[];
37
+ readonly retained: readonly string[];
38
+ };
39
+ readonly activeInvariantsDelta: {
40
+ readonly added: readonly string[];
41
+ readonly removed: readonly string[];
42
+ };
43
+ }
44
+ /**
45
+ * 시계열 감쇠 가중치 계산기 및 타임라인 분석기 클래스 (SRP 준수)
46
+ */
47
+ export declare class CausalTimeSeriesEngine {
48
+ private readonly contextStore;
49
+ constructor(contextStore?: ContextCheckpointStore, _memoryStore?: unknown);
50
+ /**
51
+ * 시계열 감쇠 지수 가중치 산출 (시간 경과 감쇠 + 빈도 가산)
52
+ * Score = BaseScore * exp(-lambda * deltaHours) + alpha * ln(1 + hitCount)
53
+ */
54
+ static calculateTemporalDecayScore(options: {
55
+ baseScore?: number;
56
+ lastActiveMs: number;
57
+ nowMs?: number;
58
+ halfLifeHours?: number;
59
+ hitCount?: number;
60
+ }): number;
61
+ /**
62
+ * 공명 인과 규칙들에 시계열 시간 감쇠 가중치 계산 반영
63
+ */
64
+ computeDecayedResonance<T extends {
65
+ updatedAt?: string;
66
+ confidence?: number;
67
+ weight?: number;
68
+ }>(rules: readonly T[]): Array<T & {
69
+ decayScore: number;
70
+ }>;
71
+ /**
72
+ * 특정 세션 또는 전체 작업의 시계열 타임라인 궤적 생성
73
+ */
74
+ generateTimeline(options?: number | {
75
+ sessionId?: string;
76
+ sinceMs?: number;
77
+ limit?: number;
78
+ }): TimelineEvent[];
79
+ /**
80
+ * 두 체크포인트 간의 차분(Diff) 계산
81
+ */
82
+ diffCheckpoints(fromId: string, toId: string): CheckpointDiffResult;
83
+ /**
84
+ * 특정 시점으로 컨텍스트 되감기(Rewind)
85
+ * 지정한 체크포인트를 최신 체크포인트로 재발행(Clone)하여 안전하게 되돌림
86
+ */
87
+ rewindToCheckpoint(targetIdOrTag: string): Promise<ContextCheckpoint>;
88
+ /**
89
+ * 시계열 차분 결과 마크다운 렌더러
90
+ */
91
+ static formatDiffReport(diff: CheckpointDiffResult): string;
92
+ }