stratagate-dsh 0.3.40 → 0.3.41

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 (42) hide show
  1. package/CHANGELOG.md +732 -732
  2. package/CONTRIBUTING.md +99 -88
  3. package/CONTRIBUTING.zh-CN.md +90 -88
  4. package/LICENSE +21 -21
  5. package/README.md +510 -489
  6. package/README.zh-CN.md +514 -493
  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 +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/plugin.js +130 -49
  13. package/dist/plugin.js.map +1 -1
  14. package/dist/repair-profile.js +0 -0
  15. package/dist/repair-profile.js.map +1 -1
  16. package/docs/ARCHITECTURE.md +282 -282
  17. package/docs/DSH.md +337 -337
  18. package/docs/DSH.zh-CN.md +325 -325
  19. package/docs/EVALUATION.md +189 -189
  20. package/docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md +99 -99
  21. package/docs/MEMORY_TOPICS.zh-CN.md +51 -51
  22. package/docs/benchmarks/issue-128-windows-review.json +104 -104
  23. package/docs/benchmarks/issue-128-windows.json +103 -103
  24. package/docs/database-access.md +32 -32
  25. package/docs/dreaming-agent.md +69 -69
  26. package/docs/event-extractor.md +48 -48
  27. package/docs/feedback.md +50 -50
  28. package/docs/issue-128-lease-cache-review-followup.md +55 -55
  29. package/docs/issue-128-review-followup.md +58 -58
  30. package/docs/knowledge-graph.md +38 -38
  31. package/docs/npm-release.md +55 -53
  32. package/docs/surface-maintenance.md +36 -36
  33. package/docs/user-operation-priority.md +46 -39
  34. package/docs/validation/issue119-after.json +30 -0
  35. package/docs/validation/issue119-before.json +94 -0
  36. package/docs/validation/issue119.md +41 -41
  37. package/docs/validation/workspace-cleanup-20261020.md +36 -36
  38. package/package.json +256 -255
  39. package/packages/core/examples/basic.ts +87 -87
  40. package/packages/core/src/blocks.ts +442 -442
  41. package/packages/core/src/weights.ts +21 -21
  42. 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();