opencodekit 0.21.8 → 0.21.10
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/dist/index.js +1 -1
- package/dist/template/.opencode/.template-manifest.json +0 -3
- package/dist/template/.opencode/AGENTS.md +1 -13
- package/dist/template/.opencode/agent/build.md +1 -1
- package/dist/template/.opencode/agent/explore.md +15 -15
- package/dist/template/.opencode/agent/general.md +2 -2
- package/dist/template/.opencode/agent/plan.md +3 -3
- package/dist/template/.opencode/agent/review.md +2 -2
- package/dist/template/.opencode/agent/scout.md +34 -15
- package/dist/template/.opencode/command/design.md +4 -4
- package/dist/template/.opencode/command/init-context.md +7 -7
- package/dist/template/.opencode/command/review-codebase.md +1 -1
- package/dist/template/.opencode/command/ship.md +1 -1
- package/dist/template/.opencode/dcp.jsonc +18 -46
- package/dist/template/.opencode/memory/project/user.md +1 -2
- package/dist/template/.opencode/opencode.json +10 -332
- package/dist/template/.opencode/plugin/lib/capture.ts +1 -1
- package/dist/template/.opencode/plugin/lib/db/schema.ts +102 -9
- package/dist/template/.opencode/plugin/lib/memory-db.ts +41 -17
- package/dist/template/.opencode/plugin/lib/operation-log.ts +1 -0
- package/dist/template/.opencode/plugin/sessions.ts +37 -8
- package/dist/template/.opencode/skill/agent-evals/SKILL.md +1 -1
- package/dist/template/.opencode/skill/code-search-patterns/SKILL.md +49 -78
- package/dist/template/.opencode/skill/context-initialization/SKILL.md +5 -5
- package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +1 -1
- package/dist/template/.opencode/tool/context7.ts +1 -1
- package/dist/template/.opencode/tool/grepsearch.ts +1 -1
- package/package.json +2 -2
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json.tui-migration.bak +0 -1380
- package/dist/template/.opencode/plugin/notification.ts.bak +0 -64
- package/dist/template/.opencode/pnpm-lock.yaml +0 -287
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://opencode.ai/config.json",
|
|
3
|
+
"lsp": true,
|
|
3
4
|
"agent": {
|
|
4
5
|
"build": {
|
|
5
6
|
"description": "Primary development agent with full codebase access",
|
|
6
|
-
"model": "github-copilot/gpt-5.
|
|
7
|
+
"model": "github-copilot/gpt-5.4"
|
|
7
8
|
},
|
|
8
9
|
"compaction": {
|
|
9
10
|
"description": "Session summarizer for context continuity across compactions"
|
|
@@ -39,8 +40,8 @@
|
|
|
39
40
|
},
|
|
40
41
|
"autoupdate": false,
|
|
41
42
|
"compaction": {
|
|
42
|
-
"auto":
|
|
43
|
-
"reserved":
|
|
43
|
+
"auto": true,
|
|
44
|
+
"reserved": 2048
|
|
44
45
|
},
|
|
45
46
|
"formatter": {
|
|
46
47
|
"biome": {
|
|
@@ -61,25 +62,6 @@
|
|
|
61
62
|
"laravel-pint": {
|
|
62
63
|
"command": ["npx", "laravel-pint", "--preset", "psr12", "$FILE"],
|
|
63
64
|
"extensions": [".php"]
|
|
64
|
-
},
|
|
65
|
-
"oxfmt": {
|
|
66
|
-
"command": ["npx", "oxfmt", "--write", "$FILE"],
|
|
67
|
-
"extensions": [
|
|
68
|
-
".js",
|
|
69
|
-
".jsx",
|
|
70
|
-
".ts",
|
|
71
|
-
".tsx",
|
|
72
|
-
".json",
|
|
73
|
-
".jsonc",
|
|
74
|
-
".html",
|
|
75
|
-
".css",
|
|
76
|
-
".scss",
|
|
77
|
-
".sass",
|
|
78
|
-
".md",
|
|
79
|
-
".mdx",
|
|
80
|
-
".yaml",
|
|
81
|
-
".yml"
|
|
82
|
-
]
|
|
83
65
|
}
|
|
84
66
|
},
|
|
85
67
|
"instructions": [
|
|
@@ -90,6 +72,9 @@
|
|
|
90
72
|
],
|
|
91
73
|
"keybinds": {
|
|
92
74
|
"leader": "ctrl+x",
|
|
75
|
+
"session_child_first": "<leader>down",
|
|
76
|
+
"session_child_cycle": "right",
|
|
77
|
+
"session_child_cycle_reverse": "left",
|
|
93
78
|
"session_parent": "up"
|
|
94
79
|
},
|
|
95
80
|
"mcp": {
|
|
@@ -99,15 +84,6 @@
|
|
|
99
84
|
"timeout": 120000,
|
|
100
85
|
"type": "local"
|
|
101
86
|
},
|
|
102
|
-
"tilth": {
|
|
103
|
-
"command": ["npx", "-y", "tilth", "--mcp", "--edit"],
|
|
104
|
-
"enabled": true,
|
|
105
|
-
"environment": {
|
|
106
|
-
"TILTH_THREADS": "8"
|
|
107
|
-
},
|
|
108
|
-
"timeout": 120000,
|
|
109
|
-
"type": "local"
|
|
110
|
-
},
|
|
111
87
|
"webclaw": {
|
|
112
88
|
"command": ["webclaw-mcp"],
|
|
113
89
|
"enabled": true,
|
|
@@ -115,7 +91,7 @@
|
|
|
115
91
|
"type": "local"
|
|
116
92
|
}
|
|
117
93
|
},
|
|
118
|
-
"model": "github-copilot/gpt-5.
|
|
94
|
+
"model": "github-copilot/gpt-5.4",
|
|
119
95
|
"permission": {
|
|
120
96
|
"bash": {
|
|
121
97
|
"*": "allow",
|
|
@@ -197,11 +173,11 @@
|
|
|
197
173
|
}
|
|
198
174
|
}
|
|
199
175
|
},
|
|
200
|
-
"claude-opus-4.
|
|
176
|
+
"claude-opus-4.7": {
|
|
201
177
|
"attachment": true,
|
|
202
178
|
"limit": {
|
|
203
179
|
"context": 216000,
|
|
204
|
-
"output":
|
|
180
|
+
"output": 64000
|
|
205
181
|
},
|
|
206
182
|
"options": {
|
|
207
183
|
"reasoningEffort": "medium"
|
|
@@ -210,16 +186,6 @@
|
|
|
210
186
|
"temperature": true,
|
|
211
187
|
"tool_call": true,
|
|
212
188
|
"variants": {
|
|
213
|
-
"high": {
|
|
214
|
-
"options": {
|
|
215
|
-
"reasoningEffort": "high"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
"low": {
|
|
219
|
-
"options": {
|
|
220
|
-
"reasoningEffort": "low"
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
189
|
"medium": {
|
|
224
190
|
"options": {
|
|
225
191
|
"reasoningEffort": "medium"
|
|
@@ -257,36 +223,6 @@
|
|
|
257
223
|
}
|
|
258
224
|
}
|
|
259
225
|
},
|
|
260
|
-
"claude-sonnet-4.5": {
|
|
261
|
-
"attachment": true,
|
|
262
|
-
"limit": {
|
|
263
|
-
"context": 216000,
|
|
264
|
-
"output": 32000
|
|
265
|
-
},
|
|
266
|
-
"options": {
|
|
267
|
-
"reasoningEffort": "medium"
|
|
268
|
-
},
|
|
269
|
-
"reasoning": true,
|
|
270
|
-
"temperature": true,
|
|
271
|
-
"tool_call": true,
|
|
272
|
-
"variants": {
|
|
273
|
-
"high": {
|
|
274
|
-
"options": {
|
|
275
|
-
"reasoningEffort": "high"
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
"low": {
|
|
279
|
-
"options": {
|
|
280
|
-
"reasoningEffort": "low"
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
"medium": {
|
|
284
|
-
"options": {
|
|
285
|
-
"reasoningEffort": "medium"
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
226
|
"claude-sonnet-4.6": {
|
|
291
227
|
"attachment": true,
|
|
292
228
|
"limit": {
|
|
@@ -317,16 +253,6 @@
|
|
|
317
253
|
}
|
|
318
254
|
}
|
|
319
255
|
},
|
|
320
|
-
"gemini-2.5-pro": {
|
|
321
|
-
"attachment": true,
|
|
322
|
-
"limit": {
|
|
323
|
-
"context": 173000,
|
|
324
|
-
"output": 64000
|
|
325
|
-
},
|
|
326
|
-
"reasoning": true,
|
|
327
|
-
"temperature": true,
|
|
328
|
-
"tool_call": true
|
|
329
|
-
},
|
|
330
256
|
"gemini-3-flash-preview": {
|
|
331
257
|
"attachment": true,
|
|
332
258
|
"limit": {
|
|
@@ -357,82 +283,6 @@
|
|
|
357
283
|
"temperature": true,
|
|
358
284
|
"tool_call": true
|
|
359
285
|
},
|
|
360
|
-
"gpt-5.2": {
|
|
361
|
-
"attachment": true,
|
|
362
|
-
"limit": {
|
|
363
|
-
"context": 192000,
|
|
364
|
-
"output": 128000
|
|
365
|
-
},
|
|
366
|
-
"options": {
|
|
367
|
-
"reasoningEffort": "medium",
|
|
368
|
-
"reasoningSummary": "auto",
|
|
369
|
-
"textVerbosity": "medium"
|
|
370
|
-
},
|
|
371
|
-
"reasoning": true,
|
|
372
|
-
"temperature": true,
|
|
373
|
-
"tool_call": true,
|
|
374
|
-
"variants": {
|
|
375
|
-
"xhigh": {
|
|
376
|
-
"include": ["reasoning.encrypted_content"],
|
|
377
|
-
"reasoningEffort": "xhigh",
|
|
378
|
-
"reasoningSummary": "auto"
|
|
379
|
-
},
|
|
380
|
-
"high": {
|
|
381
|
-
"include": ["reasoning.encrypted_content"],
|
|
382
|
-
"reasoningEffort": "high",
|
|
383
|
-
"reasoningSummary": "auto"
|
|
384
|
-
},
|
|
385
|
-
"low": {
|
|
386
|
-
"reasoningEffort": "low",
|
|
387
|
-
"reasoningSummary": "auto"
|
|
388
|
-
},
|
|
389
|
-
"medium": {
|
|
390
|
-
"reasoningEffort": "medium",
|
|
391
|
-
"reasoningSummary": "auto"
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
|
-
"gpt-5.2-codex": {
|
|
396
|
-
"attachment": true,
|
|
397
|
-
"limit": {
|
|
398
|
-
"context": 400000,
|
|
399
|
-
"input": 400000,
|
|
400
|
-
"output": 128000
|
|
401
|
-
},
|
|
402
|
-
"options": {
|
|
403
|
-
"reasoningEffort": "medium",
|
|
404
|
-
"reasoningSummary": "auto",
|
|
405
|
-
"textVerbosity": "medium"
|
|
406
|
-
},
|
|
407
|
-
"reasoning": true,
|
|
408
|
-
"temperature": true,
|
|
409
|
-
"tool_call": true,
|
|
410
|
-
"variants": {
|
|
411
|
-
"fast": {
|
|
412
|
-
"disabled": true
|
|
413
|
-
},
|
|
414
|
-
"xhigh": {
|
|
415
|
-
"include": ["reasoning.encrypted_content"],
|
|
416
|
-
"reasoningEffort": "xhigh",
|
|
417
|
-
"reasoningSummary": "auto"
|
|
418
|
-
},
|
|
419
|
-
"high": {
|
|
420
|
-
"include": ["reasoning.encrypted_content"],
|
|
421
|
-
"reasoningEffort": "high",
|
|
422
|
-
"reasoningSummary": "auto",
|
|
423
|
-
"textVerbosity": "medium"
|
|
424
|
-
},
|
|
425
|
-
"low": {
|
|
426
|
-
"reasoningEffort": "low",
|
|
427
|
-
"reasoningSummary": "auto"
|
|
428
|
-
},
|
|
429
|
-
"medium": {
|
|
430
|
-
"reasoningEffort": "medium",
|
|
431
|
-
"reasoningSummary": "auto",
|
|
432
|
-
"textVerbosity": "medium"
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
286
|
"gpt-5.3-codex": {
|
|
437
287
|
"attachment": true,
|
|
438
288
|
"limit": {
|
|
@@ -595,120 +445,12 @@
|
|
|
595
445
|
"reasoningSummary": "auto"
|
|
596
446
|
}
|
|
597
447
|
}
|
|
598
|
-
},
|
|
599
|
-
"grok-code-fast": {
|
|
600
|
-
"attachment": true,
|
|
601
|
-
"limit": {
|
|
602
|
-
"context": 173000,
|
|
603
|
-
"output": 64000
|
|
604
|
-
},
|
|
605
|
-
"reasoning": true,
|
|
606
|
-
"temperature": true,
|
|
607
|
-
"tool_call": true
|
|
608
|
-
},
|
|
609
|
-
"grok-code-fast-1": {
|
|
610
|
-
"attachment": true,
|
|
611
|
-
"limit": {
|
|
612
|
-
"context": 173000,
|
|
613
|
-
"output": 64000
|
|
614
|
-
},
|
|
615
|
-
"reasoning": true,
|
|
616
|
-
"temperature": true,
|
|
617
|
-
"tool_call": true
|
|
618
|
-
},
|
|
619
|
-
"minimax-m2.5": {
|
|
620
|
-
"attachment": true,
|
|
621
|
-
"limit": {
|
|
622
|
-
"context": 204800,
|
|
623
|
-
"output": 16384
|
|
624
|
-
},
|
|
625
|
-
"options": {
|
|
626
|
-
"temperature": 1,
|
|
627
|
-
"top_k": 40,
|
|
628
|
-
"top_p": 0.95
|
|
629
|
-
},
|
|
630
|
-
"reasoning": true,
|
|
631
|
-
"temperature": true,
|
|
632
|
-
"tool_call": true
|
|
633
448
|
}
|
|
634
449
|
},
|
|
635
450
|
"options": {
|
|
636
451
|
"timeout": 600000
|
|
637
452
|
}
|
|
638
453
|
},
|
|
639
|
-
"kimi-for-coding": {
|
|
640
|
-
"models": {
|
|
641
|
-
"k2p5": {
|
|
642
|
-
"limit": {
|
|
643
|
-
"context": 262144,
|
|
644
|
-
"output": 32768
|
|
645
|
-
},
|
|
646
|
-
"options": {
|
|
647
|
-
"interleaved": {
|
|
648
|
-
"field": "reasoning_content"
|
|
649
|
-
},
|
|
650
|
-
"thinking": {
|
|
651
|
-
"budgetTokens": 8192,
|
|
652
|
-
"reasoning_effort": "high",
|
|
653
|
-
"type": "enabled"
|
|
654
|
-
}
|
|
655
|
-
},
|
|
656
|
-
"reasoning": true,
|
|
657
|
-
"temperature": true,
|
|
658
|
-
"tool_call": true,
|
|
659
|
-
"variants": {
|
|
660
|
-
"high": {
|
|
661
|
-
"interleaved": {
|
|
662
|
-
"field": "reasoning_content"
|
|
663
|
-
},
|
|
664
|
-
"options": {
|
|
665
|
-
"reasoning_effort": "high",
|
|
666
|
-
"thinkingBudget": 16384,
|
|
667
|
-
"type": "enabled"
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
"max": {
|
|
671
|
-
"interleaved": {
|
|
672
|
-
"field": "reasoning_content"
|
|
673
|
-
},
|
|
674
|
-
"options": {
|
|
675
|
-
"reasoning_effort": "high",
|
|
676
|
-
"thinkingBudget": 32768,
|
|
677
|
-
"type": "enabled"
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
},
|
|
684
|
-
"modal": {
|
|
685
|
-
"models": {
|
|
686
|
-
"zai-org/GLM-5-FP8": {
|
|
687
|
-
"modalities": {
|
|
688
|
-
"input": ["text", "image", "pdf"],
|
|
689
|
-
"output": ["text"]
|
|
690
|
-
},
|
|
691
|
-
"name": "GLM-5",
|
|
692
|
-
"options": {
|
|
693
|
-
"maxOutputTokens": 131072,
|
|
694
|
-
"reasoningEffort": "high",
|
|
695
|
-
"reasoningSummary": "true",
|
|
696
|
-
"temperature": 1,
|
|
697
|
-
"thinking": {
|
|
698
|
-
"type": "enabled"
|
|
699
|
-
},
|
|
700
|
-
"top_k": 40,
|
|
701
|
-
"top_p": 0.95
|
|
702
|
-
},
|
|
703
|
-
"reasoning": true
|
|
704
|
-
}
|
|
705
|
-
},
|
|
706
|
-
"name": "Modal",
|
|
707
|
-
"options": {
|
|
708
|
-
"apiKey": "{env:MODAL_API_KEY}",
|
|
709
|
-
"baseURL": "https://api.us-west-2.modal.direct/v1"
|
|
710
|
-
}
|
|
711
|
-
},
|
|
712
454
|
"openai": {
|
|
713
455
|
"models": {
|
|
714
456
|
"gpt-5.2": {
|
|
@@ -816,19 +558,6 @@
|
|
|
816
558
|
}
|
|
817
559
|
}
|
|
818
560
|
},
|
|
819
|
-
"opencode": {
|
|
820
|
-
"models": {
|
|
821
|
-
"big-pickle": {
|
|
822
|
-
"options": {
|
|
823
|
-
"reasoningEffort": "high",
|
|
824
|
-
"temperature": 1,
|
|
825
|
-
"top_k": 40,
|
|
826
|
-
"top_p": 0.95
|
|
827
|
-
},
|
|
828
|
-
"reasoning": true
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
},
|
|
832
561
|
"proxypal": {
|
|
833
562
|
"models": {
|
|
834
563
|
"claude-opus-4.6": {
|
|
@@ -1080,57 +809,6 @@
|
|
|
1080
809
|
"baseURL": "http://127.0.0.1:8317/v1",
|
|
1081
810
|
"includeUsage": true
|
|
1082
811
|
}
|
|
1083
|
-
},
|
|
1084
|
-
"zai-coding-plan": {
|
|
1085
|
-
"models": {
|
|
1086
|
-
"glm-4.6": {
|
|
1087
|
-
"limit": {
|
|
1088
|
-
"context": 128000,
|
|
1089
|
-
"output": 16384
|
|
1090
|
-
},
|
|
1091
|
-
"options": {
|
|
1092
|
-
"temperature": 1,
|
|
1093
|
-
"thinking": {
|
|
1094
|
-
"type": "enabled"
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
"reasoning": true,
|
|
1098
|
-
"temperature": true,
|
|
1099
|
-
"tool_call": true
|
|
1100
|
-
},
|
|
1101
|
-
"glm-4.7": {
|
|
1102
|
-
"id": "glm-4.7",
|
|
1103
|
-
"interleaved": true,
|
|
1104
|
-
"limit": {
|
|
1105
|
-
"context": 200000,
|
|
1106
|
-
"output": 128000
|
|
1107
|
-
},
|
|
1108
|
-
"name": "GLM-4.7",
|
|
1109
|
-
"options": {
|
|
1110
|
-
"temperature": 1,
|
|
1111
|
-
"thinking": {
|
|
1112
|
-
"type": "enabled"
|
|
1113
|
-
}
|
|
1114
|
-
},
|
|
1115
|
-
"reasoning": true
|
|
1116
|
-
},
|
|
1117
|
-
"glm-5": {
|
|
1118
|
-
"name": "GLM-5",
|
|
1119
|
-
"options": {
|
|
1120
|
-
"maxOutputTokens": 131072,
|
|
1121
|
-
"reasoningEffort": "high",
|
|
1122
|
-
"reasoningSummary": "true",
|
|
1123
|
-
"temperature": 1,
|
|
1124
|
-
"thinking": {
|
|
1125
|
-
"type": "enabled"
|
|
1126
|
-
},
|
|
1127
|
-
"top_k": 40,
|
|
1128
|
-
"top_p": 0.95
|
|
1129
|
-
},
|
|
1130
|
-
"reasoning": true
|
|
1131
|
-
}
|
|
1132
|
-
},
|
|
1133
|
-
"name": "Z.AI Coding Plan"
|
|
1134
812
|
}
|
|
1135
813
|
},
|
|
1136
814
|
"share": "manual",
|
|
@@ -5,9 +5,104 @@
|
|
|
5
5
|
* singleton database connection manager.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Database } from "bun:sqlite";
|
|
9
8
|
import { appendFileSync, existsSync, renameSync } from "node:fs";
|
|
10
9
|
import path from "node:path";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
|
|
12
|
+
type SqlParam = string | number | bigint | null | Uint8Array;
|
|
13
|
+
type RunResult = { changes: number; lastInsertRowid: number | bigint };
|
|
14
|
+
type StatementResult = {
|
|
15
|
+
changes: number | bigint;
|
|
16
|
+
lastInsertRowid: number | bigint;
|
|
17
|
+
};
|
|
18
|
+
type StatementSyncLike = {
|
|
19
|
+
get(...params: SqlParam[]): unknown;
|
|
20
|
+
all(...params: SqlParam[]): unknown[];
|
|
21
|
+
run(...params: SqlParam[]): StatementResult;
|
|
22
|
+
};
|
|
23
|
+
type DatabaseSyncLike = {
|
|
24
|
+
prepare(sql: string): StatementSyncLike;
|
|
25
|
+
exec(sql: string): void;
|
|
26
|
+
close(): void;
|
|
27
|
+
};
|
|
28
|
+
type DatabaseSyncConstructor = new (
|
|
29
|
+
dbPath: string,
|
|
30
|
+
options?: { readOnly?: boolean; timeout?: number },
|
|
31
|
+
) => DatabaseSyncLike;
|
|
32
|
+
|
|
33
|
+
const require = createRequire(import.meta.url);
|
|
34
|
+
let DatabaseSyncCtor: DatabaseSyncConstructor | null = null;
|
|
35
|
+
|
|
36
|
+
function getDatabaseSyncConstructor(): DatabaseSyncConstructor {
|
|
37
|
+
if (!DatabaseSyncCtor) {
|
|
38
|
+
const sqlite = require("node:sqlite") as {
|
|
39
|
+
DatabaseSync: DatabaseSyncConstructor;
|
|
40
|
+
};
|
|
41
|
+
DatabaseSyncCtor = sqlite.DatabaseSync;
|
|
42
|
+
}
|
|
43
|
+
return DatabaseSyncCtor;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function normalizeParams(params: SqlParam[] | [SqlParam[]]): SqlParam[] {
|
|
47
|
+
if (params.length === 1 && Array.isArray(params[0])) {
|
|
48
|
+
return params[0];
|
|
49
|
+
}
|
|
50
|
+
return params as SqlParam[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Database {
|
|
54
|
+
private readonly db: DatabaseSyncLike;
|
|
55
|
+
|
|
56
|
+
constructor(
|
|
57
|
+
dbPath: string,
|
|
58
|
+
options: { create?: boolean; readonly?: boolean } = {},
|
|
59
|
+
) {
|
|
60
|
+
const DatabaseSync = getDatabaseSyncConstructor();
|
|
61
|
+
this.db = new DatabaseSync(dbPath, {
|
|
62
|
+
readOnly: options.readonly ?? false,
|
|
63
|
+
timeout: 5000,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
run(sql: string, ...params: SqlParam[] | [SqlParam[]]): RunResult {
|
|
68
|
+
const result = this.db.prepare(sql).run(...normalizeParams(params));
|
|
69
|
+
return {
|
|
70
|
+
changes: Number(result.changes),
|
|
71
|
+
lastInsertRowid: result.lastInsertRowid,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
query<Result = unknown, Params extends SqlParam[] = SqlParam[]>(sql: string) {
|
|
76
|
+
const statement = this.db.prepare(sql);
|
|
77
|
+
return {
|
|
78
|
+
get: (...params: Params | [Params]) =>
|
|
79
|
+
statement.get(
|
|
80
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
81
|
+
) as Result | null,
|
|
82
|
+
all: (...params: Params | [Params]) =>
|
|
83
|
+
statement.all(
|
|
84
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
85
|
+
) as Result[],
|
|
86
|
+
run: (...params: Params | [Params]): RunResult => {
|
|
87
|
+
const result = statement.run(
|
|
88
|
+
...normalizeParams(params as SqlParam[] | [SqlParam[]]),
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
changes: Number(result.changes),
|
|
92
|
+
lastInsertRowid: result.lastInsertRowid,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
exec(sql: string): void {
|
|
99
|
+
this.db.exec(sql);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
close(): void {
|
|
103
|
+
this.db.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
11
106
|
|
|
12
107
|
// ============================================================================
|
|
13
108
|
// Recovery Logger
|
|
@@ -355,7 +450,10 @@ export function getMemoryDB(): Database {
|
|
|
355
450
|
// Close bad instance and attempt recovery
|
|
356
451
|
dbInstance.close();
|
|
357
452
|
dbInstance = null;
|
|
358
|
-
const recovered = attemptDBRecovery(
|
|
453
|
+
const recovered = attemptDBRecovery(
|
|
454
|
+
dbPath,
|
|
455
|
+
new Error("integrity check failed"),
|
|
456
|
+
);
|
|
359
457
|
if (!recovered) {
|
|
360
458
|
throw new Error(
|
|
361
459
|
`Memory database integrity check failed and recovery failed. ` +
|
|
@@ -365,10 +463,7 @@ export function getMemoryDB(): Database {
|
|
|
365
463
|
dbInstance = recovered;
|
|
366
464
|
}
|
|
367
465
|
} catch (err) {
|
|
368
|
-
if (
|
|
369
|
-
err instanceof Error &&
|
|
370
|
-
err.message.includes("recovery failed")
|
|
371
|
-
) {
|
|
466
|
+
if (err instanceof Error && err.message.includes("recovery failed")) {
|
|
372
467
|
throw err;
|
|
373
468
|
}
|
|
374
469
|
// integrity_check itself failed — try recovery
|
|
@@ -442,9 +537,7 @@ function attemptDBRecovery(
|
|
|
442
537
|
if (existsSync(dbPath)) {
|
|
443
538
|
const backupPath = `${dbPath}.corrupt.${Date.now()}`;
|
|
444
539
|
renameSync(dbPath, backupPath);
|
|
445
|
-
logRecovery(
|
|
446
|
-
`[memory-db] Corrupt database backed up to: ${backupPath}`,
|
|
447
|
-
);
|
|
540
|
+
logRecovery(`[memory-db] Corrupt database backed up to: ${backupPath}`);
|
|
448
541
|
|
|
449
542
|
// Also clean up WAL/SHM files
|
|
450
543
|
for (const suffix of ["-wal", "-shm"]) {
|
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
* db/graph.ts — Entity graph: temporal triples, queries, stats
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
export {
|
|
17
|
+
type CompiledArticle,
|
|
18
|
+
type CompileResult,
|
|
19
|
+
type ConceptCluster,
|
|
20
|
+
compileObservations,
|
|
21
|
+
} from "./compile.js";
|
|
22
|
+
// Entity Graph Operations (v3)
|
|
23
|
+
export {
|
|
24
|
+
addEntityTriple,
|
|
25
|
+
findContradictions as findGraphContradictions,
|
|
26
|
+
getEntityGraphStats,
|
|
27
|
+
getEntityTimeline,
|
|
28
|
+
getTripleById,
|
|
29
|
+
invalidateTriple,
|
|
30
|
+
queryEntity,
|
|
31
|
+
} from "./db/graph.js";
|
|
16
32
|
// Memory Files, FTS5, and Maintenance
|
|
17
33
|
export {
|
|
18
34
|
archiveOldObservations,
|
|
@@ -53,24 +69,32 @@ export {
|
|
|
53
69
|
storeDistillation,
|
|
54
70
|
storeTemporalMessage,
|
|
55
71
|
} from "./db/pipeline.js";
|
|
56
|
-
// Entity Graph Operations (v3)
|
|
57
|
-
export {
|
|
58
|
-
addEntityTriple,
|
|
59
|
-
findContradictions as findGraphContradictions,
|
|
60
|
-
getEntityGraphStats,
|
|
61
|
-
getEntityTimeline,
|
|
62
|
-
getTripleById,
|
|
63
|
-
invalidateTriple,
|
|
64
|
-
queryEntity,
|
|
65
|
-
} from "./db/graph.js";
|
|
66
72
|
// Database Manager
|
|
67
|
-
export { closeMemoryDB, getMemoryDB } from "./db/schema.js";
|
|
73
|
+
export { closeMemoryDB, Database, getMemoryDB } from "./db/schema.js";
|
|
68
74
|
// Types & Configuration
|
|
69
75
|
export * from "./db/types.js";
|
|
70
|
-
|
|
76
|
+
export {
|
|
77
|
+
generateMemoryIndex,
|
|
78
|
+
type IndexEntry,
|
|
79
|
+
type IndexResult,
|
|
80
|
+
} from "./index-generator.js";
|
|
71
81
|
// New modules (v2.1: lint, compile, index, validate, operation log)
|
|
72
|
-
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
export {
|
|
83
|
+
type LintIssue,
|
|
84
|
+
type LintIssueType,
|
|
85
|
+
type LintResult,
|
|
86
|
+
lintMemory,
|
|
87
|
+
} from "./lint.js";
|
|
88
|
+
export {
|
|
89
|
+
appendOperationLog,
|
|
90
|
+
getLogContent,
|
|
91
|
+
getRecentLogEntries,
|
|
92
|
+
type LogEntry,
|
|
93
|
+
type OperationType,
|
|
94
|
+
} from "./operation-log.js";
|
|
95
|
+
export {
|
|
96
|
+
type ValidationIssue,
|
|
97
|
+
type ValidationResult,
|
|
98
|
+
type ValidationVerdict,
|
|
99
|
+
validateObservation,
|
|
100
|
+
} from "./validate.js";
|