stratagate-dsh 0.3.33 → 0.3.35

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 (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CONTRIBUTING.md +88 -88
  3. package/CONTRIBUTING.zh-CN.md +88 -88
  4. package/LICENSE +21 -21
  5. package/README.md +487 -487
  6. package/README.zh-CN.md +491 -491
  7. package/benchmarks/locomo-conv26-r8-final.json +146 -146
  8. package/cordis.patch.yml +16 -16
  9. package/dist/client.d.ts +1 -1
  10. package/dist/client.js +4 -4
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/plugin.d.ts +3 -0
  14. package/dist/plugin.js +992 -157
  15. package/dist/plugin.js.map +1 -1
  16. package/dist/repair-profile.js.map +1 -1
  17. package/docs/ARCHITECTURE.md +282 -282
  18. package/docs/DSH.md +337 -331
  19. package/docs/DSH.zh-CN.md +315 -309
  20. package/docs/EVALUATION.md +189 -189
  21. package/docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md +99 -99
  22. package/docs/MEMORY_TOPICS.zh-CN.md +51 -51
  23. package/docs/benchmarks/issue-128-windows-review.json +104 -104
  24. package/docs/benchmarks/issue-128-windows.json +103 -103
  25. package/docs/database-access.md +32 -0
  26. package/docs/dreaming-agent.md +69 -69
  27. package/docs/event-extractor.md +48 -48
  28. package/docs/feedback.md +50 -50
  29. package/docs/issue-128-lease-cache-review-followup.md +55 -55
  30. package/docs/issue-128-review-followup.md +58 -58
  31. package/docs/knowledge-graph.md +38 -38
  32. package/docs/npm-release.md +53 -53
  33. package/docs/surface-maintenance.md +36 -36
  34. package/docs/user-operation-priority.md +39 -39
  35. package/docs/validation/issue119.md +41 -41
  36. package/docs/validation/workspace-cleanup-20261020.md +36 -36
  37. package/package.json +255 -255
  38. package/packages/core/examples/basic.ts +87 -87
  39. package/packages/core/src/blocks.ts +442 -442
  40. package/packages/core/src/weights.ts +21 -21
  41. package/screenshots.json +8 -8
@@ -1,87 +1,87 @@
1
- import {
2
- StrataGate,
3
- type BlockSummarizer,
4
- type ElementProjector,
5
- type EventExtractor,
6
- } from '../src/index.js';
7
-
8
- const summarize: BlockSummarizer = async (messages) => ({
9
- l0Title: 'API design discussion',
10
- l0Tags: ['api', 'decision'],
11
- l1Summary: 'The team chose cursor pagination for the public API.',
12
- l2Keypoints: messages.map((message) => message.content),
13
- shouldExtract: true,
14
- });
15
-
16
- const extract: EventExtractor = async ({ target }) => ({
17
- shouldExtract: true,
18
- reason: 'A durable technical decision was made.',
19
- events: [{
20
- title: 'Use cursor pagination',
21
- summary: 'The public API should use cursor pagination instead of page numbers.',
22
- sourceMessageIds: target.l5Raw.filter((message) => message.role === 'user').map((message) => message.id),
23
- sourceBlockId: target.id,
24
- tags: ['api', 'pagination'],
25
- temporal: { status: 'occurred', eventType: 'decision' },
26
- }],
27
- });
28
-
29
- // Element cards are a separately retryable materialized view. The callback may
30
- // call any model provider; StrataGate validates every proposed source event ID.
31
- const projectElements: ElementProjector = async ({ events }) => ({
32
- reason: 'Update the current project view from the new immutable event.',
33
- changes: events.map((event) => ({
34
- element: { name: 'Public API', type: 'project' },
35
- operation: 'set_state',
36
- key: 'pagination',
37
- mode: 'state',
38
- value: 'cursor pagination',
39
- sourceEventIds: [event.id],
40
- confidence: 1,
41
- })),
42
- });
43
-
44
- const memory = await StrataGate.open({
45
- database: './stratagate-example.db',
46
- namespace: 'example:basic',
47
- blockTurnSize: 1,
48
- summarizer: summarize,
49
- extractor: extract,
50
- elementProjector: projectElements,
51
- });
52
-
53
- await memory.appendTurn({
54
- user: 'Let us use cursor pagination for the public API.',
55
- assistant: 'Agreed. I will treat that as the current API decision.',
56
- });
57
-
58
- // Extraction waits until the following block exists, so it can use both
59
- // earlier and later context without taking quotes from neighboring blocks.
60
- await memory.appendTurn({
61
- user: 'Now define the response envelope.',
62
- assistant: 'I will keep the pagination decision in mind.',
63
- });
64
-
65
- const results = await memory.searchEvents('How should the API paginate?');
66
- const elementFacts = await memory.searchElements('current API pagination', { type: 'project' });
67
- const evidence = new Set([
68
- ...results.map(({ event }) => event.id),
69
- ...elementFacts.map(({ id }) => id),
70
- ]);
71
- const assessment = memory.assessRetrieval({
72
- verdict: 'sufficient',
73
- evidence_refs: [...evidence],
74
- fit: 'The event card records the chosen pagination strategy.',
75
- missing: '',
76
- next_strategy: 'answer',
77
- }, evidence);
78
-
79
- if (assessment.verdict === 'sufficient') {
80
- await memory.recordMemoryUse({
81
- eventIds: results.map(({ event }) => event.id),
82
- elementIds: [...new Set(elementFacts.map(({ elementId }) => elementId))],
83
- }, { receiptId: 'example:answer:1' });
84
- console.log(elementFacts[0]?.fact.value ?? results[0]?.event.summary);
85
- }
86
-
87
- await memory.close();
1
+ import {
2
+ StrataGate,
3
+ type BlockSummarizer,
4
+ type ElementProjector,
5
+ type EventExtractor,
6
+ } from '../src/index.js';
7
+
8
+ const summarize: BlockSummarizer = async (messages) => ({
9
+ l0Title: 'API design discussion',
10
+ l0Tags: ['api', 'decision'],
11
+ l1Summary: 'The team chose cursor pagination for the public API.',
12
+ l2Keypoints: messages.map((message) => message.content),
13
+ shouldExtract: true,
14
+ });
15
+
16
+ const extract: EventExtractor = async ({ target }) => ({
17
+ shouldExtract: true,
18
+ reason: 'A durable technical decision was made.',
19
+ events: [{
20
+ title: 'Use cursor pagination',
21
+ summary: 'The public API should use cursor pagination instead of page numbers.',
22
+ sourceMessageIds: target.l5Raw.filter((message) => message.role === 'user').map((message) => message.id),
23
+ sourceBlockId: target.id,
24
+ tags: ['api', 'pagination'],
25
+ temporal: { status: 'occurred', eventType: 'decision' },
26
+ }],
27
+ });
28
+
29
+ // Element cards are a separately retryable materialized view. The callback may
30
+ // call any model provider; StrataGate validates every proposed source event ID.
31
+ const projectElements: ElementProjector = async ({ events }) => ({
32
+ reason: 'Update the current project view from the new immutable event.',
33
+ changes: events.map((event) => ({
34
+ element: { name: 'Public API', type: 'project' },
35
+ operation: 'set_state',
36
+ key: 'pagination',
37
+ mode: 'state',
38
+ value: 'cursor pagination',
39
+ sourceEventIds: [event.id],
40
+ confidence: 1,
41
+ })),
42
+ });
43
+
44
+ const memory = await StrataGate.open({
45
+ database: './stratagate-example.db',
46
+ namespace: 'example:basic',
47
+ blockTurnSize: 1,
48
+ summarizer: summarize,
49
+ extractor: extract,
50
+ elementProjector: projectElements,
51
+ });
52
+
53
+ await memory.appendTurn({
54
+ user: 'Let us use cursor pagination for the public API.',
55
+ assistant: 'Agreed. I will treat that as the current API decision.',
56
+ });
57
+
58
+ // Extraction waits until the following block exists, so it can use both
59
+ // earlier and later context without taking quotes from neighboring blocks.
60
+ await memory.appendTurn({
61
+ user: 'Now define the response envelope.',
62
+ assistant: 'I will keep the pagination decision in mind.',
63
+ });
64
+
65
+ const results = await memory.searchEvents('How should the API paginate?');
66
+ const elementFacts = await memory.searchElements('current API pagination', { type: 'project' });
67
+ const evidence = new Set([
68
+ ...results.map(({ event }) => event.id),
69
+ ...elementFacts.map(({ id }) => id),
70
+ ]);
71
+ const assessment = memory.assessRetrieval({
72
+ verdict: 'sufficient',
73
+ evidence_refs: [...evidence],
74
+ fit: 'The event card records the chosen pagination strategy.',
75
+ missing: '',
76
+ next_strategy: 'answer',
77
+ }, evidence);
78
+
79
+ if (assessment.verdict === 'sufficient') {
80
+ await memory.recordMemoryUse({
81
+ eventIds: results.map(({ event }) => event.id),
82
+ elementIds: [...new Set(elementFacts.map(({ elementId }) => elementId))],
83
+ }, { receiptId: 'example:answer:1' });
84
+ console.log(elementFacts[0]?.fact.value ?? results[0]?.event.summary);
85
+ }
86
+
87
+ await memory.close();