@yaks/dreaming 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +55 -2
- package/_dist/graph.d.ts +6 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/mod.d.ts +17 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/deno.json +1 -0
- package/graph.js +134 -0
- package/graph.js.map +1 -0
- package/graph.ts +177 -0
- package/mod.js +17 -0
- package/mod.js.map +1 -0
- package/mod.ts +20 -0
- package/package.json +25 -4
- package/vocab.js +16 -0
- package/vocab.js.map +1 -0
- package/vocab.json +108 -0
- package/vocab.ts +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Jeff Peterson
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yaks/dreaming
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Standing intentions an agent works on when nobody is asking it anything, and the
|
|
4
|
+
record of how often each memory has been recalled. It writes to the graph
|
|
5
|
+
supplied by the caller, not to a separate database.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
deno add jsr:@yaks/dreaming
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- `dream{scope}` — a standing intention filed under a project.
|
|
12
|
+
- `recall{count, first_at, last_at}` — how many times an entity has been
|
|
13
|
+
recalled, and when it last was. This is the data dreaming works over.
|
|
14
|
+
- `recalled` — an edge relation: this entry recalled that entity, at this time.
|
|
15
|
+
- `meta` — marks text in a transcript as a note: it is never delivered to anyone
|
|
16
|
+
live, and is read later by a dream.
|
|
17
|
+
|
|
18
|
+
`@yaks/dreaming/graph` adds `.order=hot` to every query: warmest first, by the
|
|
19
|
+
curve a recall decays along. Each recall earns a day of stability, spacing
|
|
20
|
+
multiplies it (the mean interval, in weeks), and the score falls off
|
|
21
|
+
exponentially past the last recall. An entity never recalled counts its own last
|
|
22
|
+
touch as one recall. A retired project, and whatever is filed under one, ranks
|
|
23
|
+
at a tenth. A page in this order (`.order=hot&.limit=400`) is looked for among
|
|
24
|
+
the recalled and the newest touches, by the indexes on `created.at` and
|
|
25
|
+
`updated.at`, and ranks every row only when those cannot make it.
|
|
26
|
+
|
|
27
|
+
The memories themselves belong to [@yaks/memory](../memory). This package covers
|
|
28
|
+
what happens to them between conversations.
|
|
29
|
+
|
|
30
|
+
## A dream is a builder
|
|
31
|
+
|
|
32
|
+
A dream runs as a [@yaks/builders](../builders) builder. It wears `builder`
|
|
33
|
+
beside `dream`; `content.body` is its template, and `builder.query` selects
|
|
34
|
+
inputs:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
import { modelToolEid } from '@yaks/builders/model'
|
|
38
|
+
|
|
39
|
+
{ entity: { eid: '$d' }, dream: { scope: 'P-1' },
|
|
40
|
+
builder: { to: modelToolEid() },
|
|
41
|
+
content: { body: 'Write up what is waiting.' } }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
When it runs, which session opens, and where the session's answer is kept are
|
|
45
|
+
@yaks/builders' decisions and configuration: list that package beside this one
|
|
46
|
+
and configure its schedule. A dream reads as a `dream` (its `Z-` id) rather than
|
|
47
|
+
as a builder or a doc. This package runs nothing itself.
|
|
48
|
+
|
|
49
|
+
## Exports
|
|
50
|
+
|
|
51
|
+
- `@yaks/dreaming`: `dreamingDoc` and the `DREAM` and `RECALL` component names.
|
|
52
|
+
- `@yaks/dreaming/vocab`: the schema in `docs`.
|
|
53
|
+
|
|
54
|
+
## Compatibility
|
|
55
|
+
|
|
56
|
+
Deno and Node. Both exports are declarations with no runtime calls.
|
package/_dist/graph.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Extension } from "@yaks/sql";
|
|
2
|
+
/** The ranking `.order=` names. */ export declare let HOT: string;
|
|
3
|
+
/** What a retired project, and what is filed under one, is worth. */ export declare let SUNK: number;
|
|
4
|
+
/** The `.order=hot` compiler. It claims no clause: a ranking only orders what
|
|
5
|
+
* the rest of the query selected. */ export declare let extend: () => Extension[];
|
|
6
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAiBA,SAQE,KAAK,SAAS,yBAkBa;AAE7B,iCAAiC,GACjC,OAAO,YAAI,YAAW;AAEtB,mEAAmE,GACnE,OAAO,YAAI,aAAU;AAwHrB;mCACmC,GACnC,OAAO,YAAI,cAAa,YAKtB"}
|
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background work an agent does when nobody is asking it anything. A `dream`
|
|
3
|
+
* is a standing intention filed under a project; `recall` is what dreaming
|
|
4
|
+
* consolidates — how many times a memory has been recalled, and when it last
|
|
5
|
+
* was. A `recalled` edge records one such recall, and a `meta` component marks
|
|
6
|
+
* text written for a dream to read later rather than for anyone right now.
|
|
7
|
+
*
|
|
8
|
+
* A dream runs as a @yaks/builders builder: it wears `builder` beside `dream`,
|
|
9
|
+
* its `content` body is the template, and @yaks/builders decides when a session
|
|
10
|
+
* opens on it and keeps what that session answered as its output. This package
|
|
11
|
+
* runs nothing itself.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/ export { dreamingDoc } from "./vocab.js";
|
|
15
|
+
/** The components this package declares. */ export declare let DREAM: string;
|
|
16
|
+
export declare let RECALL: string;
|
|
17
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GAED,SAAS,WAAW,qBAAoB;AAExC,0CAA0C,GAC1C,OAAO,YAAI,cAAe;AAC1B,OAAO,YAAI,eAAiB"}
|
package/_dist/vocab.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { VocabDoc } from "@yaks/vocab";
|
|
2
|
+
/** The dreaming vocabulary, as the document `loadVocab` accepts. */ export declare let dreamingDoc: VocabDoc;
|
|
3
|
+
/** What this package is: its manifest's description, the one place it is
|
|
4
|
+
* written, which a host stamps on each document here. */ export declare let description: string;
|
|
5
|
+
/** Every document this plugin declares. */ export declare let docs: VocabDoc[];
|
|
6
|
+
//# sourceMappingURL=vocab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,2BAAgC;AAItD,kEAAkE,GAClE,OAAO,YAAI,aAAa,SAA0B;AAElD;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,yCAAyC,GACzC,OAAO,YAAI,MAAM,WAA0B"}
|
package/deno.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/dreaming","version":"0.2.36","license":"Apache-2.0","description":"Standing intentions filed under a project, which @yaks/builders builds on a schedule, a record of how often each memory has been recalled, and the `.order=hot` ranking that record decays along.","exports":{".":"./mod.ts","./vocab":"./vocab.ts","./graph":"./graph.ts"},"imports":{"@yaks/dreaming":"./mod.ts","@yaks/dreaming/vocab":"./vocab.ts","@yaks/dreaming/graph":"./graph.ts"}}
|
package/graph.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// `.order=hot`, the `graph` export (`@yaks/dreaming/graph`): the rank a recall
|
|
2
|
+
// decays along, as an @yaks/sql ORDER BY expression every read path consults.
|
|
3
|
+
//
|
|
4
|
+
// Every recall earns a day of stability and spacing multiplies it — the mean
|
|
5
|
+
// interval, in weeks — so the same count spread over months holds longer than
|
|
6
|
+
// an afternoon of cramming. The score falls off exponentially past the last
|
|
7
|
+
// recall against that stability, on (0,1]. An entity never recalled counts its
|
|
8
|
+
// own last touch (`updated.at`, else `created.at`) as one recall, so new
|
|
9
|
+
// things start hot and fade unless used. A retired project, and every entity
|
|
10
|
+
// filed under one, keeps its curve but sinks beneath live work: a tenth.
|
|
11
|
+
//
|
|
12
|
+
// The expression reads one owner through one correlated subquery, so the row
|
|
13
|
+
// being ordered and a `.after` cursor's anchor rank the same way. A component
|
|
14
|
+
// the vocabulary lacks is read as absent. A page in this order is looked for
|
|
15
|
+
// among the newest touches and the recalled first (`opening`), so it reads
|
|
16
|
+
// about a page rather than ranking the whole graph.
|
|
17
|
+
import { and, as, col, desc, eq, exists, FALSE, fn, from, gt, iff, left, lit, neg, notNull, op, or, select, sub, union } from "@yaks/sql";
|
|
18
|
+
/** The ranking `.order=` names. */ export let HOT = 'hot';
|
|
19
|
+
/** What a retired project, and what is filed under one, is worth. */ export let SUNK = 0.1;
|
|
20
|
+
let DAY = 86_400_000;
|
|
21
|
+
// The Julian day an instant falls on, the unit SQLite's `julianday` reads.
|
|
22
|
+
let julian = (ms)=>ms / DAY + 2440587.5;
|
|
23
|
+
let warmth = (site)=>{
|
|
24
|
+
let v = site.vocab;
|
|
25
|
+
let joins = [];
|
|
26
|
+
// One component joined by alias, or every column of it read as null.
|
|
27
|
+
let read = (comp, alias)=>{
|
|
28
|
+
if (!v.comp(comp)) return ()=>lit(null);
|
|
29
|
+
joins.push(left(site.from(comp, alias), eq(col('entity', alias), col('id', '__e'))));
|
|
30
|
+
return (prop)=>prop == 'entity' || v.prop(comp, prop) ? col(prop, alias) : lit(null);
|
|
31
|
+
};
|
|
32
|
+
let r = read('recall', '__r');
|
|
33
|
+
let u = read('updated', '__u');
|
|
34
|
+
let c = read('created', '__c');
|
|
35
|
+
let p = read('project', '__p');
|
|
36
|
+
let a = read('archived', '__a');
|
|
37
|
+
let f = read('filed', '__f');
|
|
38
|
+
let day = (e)=>fn('julianday', e);
|
|
39
|
+
let count = r('count');
|
|
40
|
+
let lastAt = r('last_at');
|
|
41
|
+
let recalled = and(gt(fn('coalesce', count, lit(0)), lit(0)), notNull(lastAt));
|
|
42
|
+
let last = iff(recalled, lastAt, fn('coalesce', u('at'), c('at')));
|
|
43
|
+
let n = iff(recalled, count, lit(1));
|
|
44
|
+
let first = iff(recalled, fn('coalesce', r('first_at'), lastAt), last);
|
|
45
|
+
let span = fn('max', lit(0), op('-', day(last), day(first)));
|
|
46
|
+
let mean = iff(gt(n, lit(1)), op('/', span, op('-', n, lit(1))), lit(0));
|
|
47
|
+
let age = fn('max', lit(0), op('-', lit(julian(site.now)), day(last)));
|
|
48
|
+
let score = fn('coalesce', fn('exp', op('/', neg(age), op('*', n, op('+', lit(1), op('/', mean, lit(7)))))), lit(0));
|
|
49
|
+
let under = v.comp('archived') ? exists(select({
|
|
50
|
+
cols: [
|
|
51
|
+
lit(1)
|
|
52
|
+
],
|
|
53
|
+
from: site.from('archived', '__x'),
|
|
54
|
+
where: eq(col('entity', '__x'), f('project'))
|
|
55
|
+
})) : FALSE;
|
|
56
|
+
let retired = and(notNull(p('entity')), notNull(a('entity')));
|
|
57
|
+
let sunk = iff(or(retired, under), lit(SUNK), lit(1));
|
|
58
|
+
// Warmest first: the ranking is negated, so a plain order ascends through
|
|
59
|
+
// it and `.order=-hot` reads coldest first.
|
|
60
|
+
return neg(sub(select({
|
|
61
|
+
cols: [
|
|
62
|
+
op('*', score, sunk)
|
|
63
|
+
],
|
|
64
|
+
from: site.from('entity', '__e'),
|
|
65
|
+
joins,
|
|
66
|
+
where: eq(col('id', '__e'), site.owner)
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
69
|
+
// How many times a page's size of the newest touches it is looked for in.
|
|
70
|
+
let DEPTH = 4;
|
|
71
|
+
// Where a page of the warmest lies (@yaks/sql `Lead`). A row never recalled
|
|
72
|
+
// ranks by its last touch alone, at most `exp(-age)` whatever it is filed
|
|
73
|
+
// under, and its touch is its `updated.at`, else its `created.at`. So a row
|
|
74
|
+
// outside the newest `m` of each holds a touch no newer than the later of the
|
|
75
|
+
// two cuts, and ranks no warmer than that touch would. The recalled rows can
|
|
76
|
+
// rank warmer than their touch, and they are few, so each of them leads.
|
|
77
|
+
let opening = (site, n)=>{
|
|
78
|
+
let v = site.vocab;
|
|
79
|
+
let stamps = [
|
|
80
|
+
'updated',
|
|
81
|
+
'created'
|
|
82
|
+
].filter((c)=>v.prop(c, 'at'));
|
|
83
|
+
if (!stamps.length) return null;
|
|
84
|
+
let m = n * DEPTH;
|
|
85
|
+
// The newest `m` of a stamp, or the one they end at.
|
|
86
|
+
let newest = (comp, cols, end = false)=>select({
|
|
87
|
+
cols,
|
|
88
|
+
from: site.from(comp, '__n'),
|
|
89
|
+
order: [
|
|
90
|
+
desc(col('at', '__n'))
|
|
91
|
+
],
|
|
92
|
+
limit: lit(end ? 1 : m),
|
|
93
|
+
...end ? {
|
|
94
|
+
offset: lit(m - 1)
|
|
95
|
+
} : {}
|
|
96
|
+
});
|
|
97
|
+
let ids = (q)=>select({
|
|
98
|
+
cols: [
|
|
99
|
+
col('id')
|
|
100
|
+
],
|
|
101
|
+
from: from(q)
|
|
102
|
+
});
|
|
103
|
+
let rows = stamps.map((comp)=>ids(newest(comp, [
|
|
104
|
+
as(col('entity', '__n'), 'id')
|
|
105
|
+
])));
|
|
106
|
+
if (v.comp('recall')) {
|
|
107
|
+
rows.push(select({
|
|
108
|
+
cols: [
|
|
109
|
+
as(col('entity', '__n'), 'id')
|
|
110
|
+
],
|
|
111
|
+
from: site.from('recall', '__n')
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
// The warmest a row past a cut can be; nothing is past a cut that falls
|
|
115
|
+
// beyond the component's last row.
|
|
116
|
+
let past = (comp)=>fn('coalesce', fn('exp', neg(fn('max', lit(0), op('-', lit(julian(site.now)), fn('julianday', sub(newest(comp, [
|
|
117
|
+
col('at', '__n')
|
|
118
|
+
], true))))))), lit(0));
|
|
119
|
+
let warmest = stamps.length > 1 ? fn('max', ...stamps.map(past)) : past(stamps[0]);
|
|
120
|
+
return {
|
|
121
|
+
rows: union(...rows),
|
|
122
|
+
floor: neg(warmest)
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** The `.order=hot` compiler. It claims no clause: a ranking only orders what
|
|
126
|
+
* the rest of the query selected. */ export let extend = ()=>[
|
|
127
|
+
{
|
|
128
|
+
name: 'dreaming',
|
|
129
|
+
compile: {},
|
|
130
|
+
order: (value, site)=>value == HOT ? warmth(site) : null,
|
|
131
|
+
lead: (value, site, n)=>value == HOT ? opening(site, n) : null
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
//# sourceMappingURL=graph.js.map
|
package/graph.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sources":["./graph.ts"],"names":[],"mappings":"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"}
|
package/graph.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// `.order=hot`, the `graph` export (`@yaks/dreaming/graph`): the rank a recall
|
|
2
|
+
// decays along, as an @yaks/sql ORDER BY expression every read path consults.
|
|
3
|
+
//
|
|
4
|
+
// Every recall earns a day of stability and spacing multiplies it — the mean
|
|
5
|
+
// interval, in weeks — so the same count spread over months holds longer than
|
|
6
|
+
// an afternoon of cramming. The score falls off exponentially past the last
|
|
7
|
+
// recall against that stability, on (0,1]. An entity never recalled counts its
|
|
8
|
+
// own last touch (`updated.at`, else `created.at`) as one recall, so new
|
|
9
|
+
// things start hot and fade unless used. A retired project, and every entity
|
|
10
|
+
// filed under one, keeps its curve but sinks beneath live work: a tenth.
|
|
11
|
+
//
|
|
12
|
+
// The expression reads one owner through one correlated subquery, so the row
|
|
13
|
+
// being ordered and a `.after` cursor's anchor rank the same way. A component
|
|
14
|
+
// the vocabulary lacks is read as absent. A page in this order is looked for
|
|
15
|
+
// among the newest touches and the recalled first (`opening`), so it reads
|
|
16
|
+
// about a page rather than ranking the whole graph.
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
and,
|
|
20
|
+
as,
|
|
21
|
+
col,
|
|
22
|
+
desc,
|
|
23
|
+
eq,
|
|
24
|
+
exists,
|
|
25
|
+
type Expr,
|
|
26
|
+
type Extension,
|
|
27
|
+
FALSE,
|
|
28
|
+
fn,
|
|
29
|
+
from,
|
|
30
|
+
gt,
|
|
31
|
+
iff,
|
|
32
|
+
type Join,
|
|
33
|
+
left,
|
|
34
|
+
lit,
|
|
35
|
+
neg,
|
|
36
|
+
notNull,
|
|
37
|
+
op,
|
|
38
|
+
or,
|
|
39
|
+
type Select,
|
|
40
|
+
select,
|
|
41
|
+
type Site,
|
|
42
|
+
sub,
|
|
43
|
+
union,
|
|
44
|
+
} from '@yaks/sql'
|
|
45
|
+
|
|
46
|
+
/** The ranking `.order=` names. */
|
|
47
|
+
export let HOT = 'hot'
|
|
48
|
+
|
|
49
|
+
/** What a retired project, and what is filed under one, is worth. */
|
|
50
|
+
export let SUNK = 0.1
|
|
51
|
+
|
|
52
|
+
let DAY = 86_400_000
|
|
53
|
+
|
|
54
|
+
// The Julian day an instant falls on, the unit SQLite's `julianday` reads.
|
|
55
|
+
let julian = (ms: number) => ms / DAY + 2440587.5
|
|
56
|
+
|
|
57
|
+
let warmth = (site: Site): Expr => {
|
|
58
|
+
let v = site.vocab
|
|
59
|
+
let joins: Join[] = []
|
|
60
|
+
// One component joined by alias, or every column of it read as null.
|
|
61
|
+
let read = (comp: string, alias: string) => {
|
|
62
|
+
if (!v.comp(comp)) return () => lit(null)
|
|
63
|
+
joins.push(
|
|
64
|
+
left(site.from(comp, alias), eq(col('entity', alias), col('id', '__e'))),
|
|
65
|
+
)
|
|
66
|
+
return (prop: string) =>
|
|
67
|
+
prop == 'entity' || v.prop(comp, prop) ? col(prop, alias) : lit(null)
|
|
68
|
+
}
|
|
69
|
+
let r = read('recall', '__r')
|
|
70
|
+
let u = read('updated', '__u')
|
|
71
|
+
let c = read('created', '__c')
|
|
72
|
+
let p = read('project', '__p')
|
|
73
|
+
let a = read('archived', '__a')
|
|
74
|
+
let f = read('filed', '__f')
|
|
75
|
+
let day = (e: Expr) => fn('julianday', e)
|
|
76
|
+
let count = r('count')
|
|
77
|
+
let lastAt = r('last_at')
|
|
78
|
+
let recalled = and(gt(fn('coalesce', count, lit(0)), lit(0)), notNull(lastAt))
|
|
79
|
+
let last = iff(recalled, lastAt, fn('coalesce', u('at'), c('at')))
|
|
80
|
+
let n = iff(recalled, count, lit(1))
|
|
81
|
+
let first = iff(recalled, fn('coalesce', r('first_at'), lastAt), last)
|
|
82
|
+
let span = fn('max', lit(0), op('-', day(last), day(first)))
|
|
83
|
+
let mean = iff(gt(n, lit(1)), op('/', span, op('-', n, lit(1))), lit(0))
|
|
84
|
+
let age = fn('max', lit(0), op('-', lit(julian(site.now)), day(last)))
|
|
85
|
+
let score = fn(
|
|
86
|
+
'coalesce',
|
|
87
|
+
fn(
|
|
88
|
+
'exp',
|
|
89
|
+
op('/', neg(age), op('*', n, op('+', lit(1), op('/', mean, lit(7))))),
|
|
90
|
+
),
|
|
91
|
+
lit(0),
|
|
92
|
+
)
|
|
93
|
+
let under = v.comp('archived')
|
|
94
|
+
? exists(select({
|
|
95
|
+
cols: [lit(1)],
|
|
96
|
+
from: site.from('archived', '__x'),
|
|
97
|
+
where: eq(col('entity', '__x'), f('project')),
|
|
98
|
+
}))
|
|
99
|
+
: FALSE
|
|
100
|
+
let retired = and(notNull(p('entity')), notNull(a('entity')))
|
|
101
|
+
let sunk = iff(or(retired, under), lit(SUNK), lit(1))
|
|
102
|
+
// Warmest first: the ranking is negated, so a plain order ascends through
|
|
103
|
+
// it and `.order=-hot` reads coldest first.
|
|
104
|
+
return neg(sub(select({
|
|
105
|
+
cols: [op('*', score, sunk)],
|
|
106
|
+
from: site.from('entity', '__e'),
|
|
107
|
+
joins,
|
|
108
|
+
where: eq(col('id', '__e'), site.owner),
|
|
109
|
+
})))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// How many times a page's size of the newest touches it is looked for in.
|
|
113
|
+
let DEPTH = 4
|
|
114
|
+
|
|
115
|
+
// Where a page of the warmest lies (@yaks/sql `Lead`). A row never recalled
|
|
116
|
+
// ranks by its last touch alone, at most `exp(-age)` whatever it is filed
|
|
117
|
+
// under, and its touch is its `updated.at`, else its `created.at`. So a row
|
|
118
|
+
// outside the newest `m` of each holds a touch no newer than the later of the
|
|
119
|
+
// two cuts, and ranks no warmer than that touch would. The recalled rows can
|
|
120
|
+
// rank warmer than their touch, and they are few, so each of them leads.
|
|
121
|
+
let opening = (site: Site, n: number) => {
|
|
122
|
+
let v = site.vocab
|
|
123
|
+
let stamps = ['updated', 'created'].filter((c) => v.prop(c, 'at'))
|
|
124
|
+
if (!stamps.length) return null
|
|
125
|
+
let m = n * DEPTH
|
|
126
|
+
// The newest `m` of a stamp, or the one they end at.
|
|
127
|
+
let newest = (comp: string, cols: Expr[], end = false) =>
|
|
128
|
+
select({
|
|
129
|
+
cols,
|
|
130
|
+
from: site.from(comp, '__n'),
|
|
131
|
+
order: [desc(col('at', '__n'))],
|
|
132
|
+
limit: lit(end ? 1 : m),
|
|
133
|
+
...end ? { offset: lit(m - 1) } : {},
|
|
134
|
+
})
|
|
135
|
+
let ids = (q: Select) => select({ cols: [col('id')], from: from(q) })
|
|
136
|
+
let rows = stamps.map((comp) =>
|
|
137
|
+
ids(newest(comp, [as(col('entity', '__n'), 'id')]))
|
|
138
|
+
)
|
|
139
|
+
if (v.comp('recall')) {
|
|
140
|
+
rows.push(select({
|
|
141
|
+
cols: [as(col('entity', '__n'), 'id')],
|
|
142
|
+
from: site.from('recall', '__n'),
|
|
143
|
+
}))
|
|
144
|
+
}
|
|
145
|
+
// The warmest a row past a cut can be; nothing is past a cut that falls
|
|
146
|
+
// beyond the component's last row.
|
|
147
|
+
let past = (comp: string) =>
|
|
148
|
+
fn(
|
|
149
|
+
'coalesce',
|
|
150
|
+
fn(
|
|
151
|
+
'exp',
|
|
152
|
+
neg(fn(
|
|
153
|
+
'max',
|
|
154
|
+
lit(0),
|
|
155
|
+
op(
|
|
156
|
+
'-',
|
|
157
|
+
lit(julian(site.now)),
|
|
158
|
+
fn('julianday', sub(newest(comp, [col('at', '__n')], true))),
|
|
159
|
+
),
|
|
160
|
+
)),
|
|
161
|
+
),
|
|
162
|
+
lit(0),
|
|
163
|
+
)
|
|
164
|
+
let warmest = stamps.length > 1
|
|
165
|
+
? fn('max', ...stamps.map(past))
|
|
166
|
+
: past(stamps[0])
|
|
167
|
+
return { rows: union(...rows), floor: neg(warmest) }
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The `.order=hot` compiler. It claims no clause: a ranking only orders what
|
|
171
|
+
* the rest of the query selected. */
|
|
172
|
+
export let extend = (): Extension[] => [{
|
|
173
|
+
name: 'dreaming',
|
|
174
|
+
compile: {},
|
|
175
|
+
order: (value, site) => value == HOT ? warmth(site) : null,
|
|
176
|
+
lead: (value, site, n) => value == HOT ? opening(site, n) : null,
|
|
177
|
+
}]
|
package/mod.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background work an agent does when nobody is asking it anything. A `dream`
|
|
3
|
+
* is a standing intention filed under a project; `recall` is what dreaming
|
|
4
|
+
* consolidates — how many times a memory has been recalled, and when it last
|
|
5
|
+
* was. A `recalled` edge records one such recall, and a `meta` component marks
|
|
6
|
+
* text written for a dream to read later rather than for anyone right now.
|
|
7
|
+
*
|
|
8
|
+
* A dream runs as a @yaks/builders builder: it wears `builder` beside `dream`,
|
|
9
|
+
* its `content` body is the template, and @yaks/builders decides when a session
|
|
10
|
+
* opens on it and keeps what that session answered as its output. This package
|
|
11
|
+
* runs nothing itself.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/ export { dreamingDoc } from "./vocab.js";
|
|
15
|
+
/** The components this package declares. */ export let DREAM = 'dream';
|
|
16
|
+
export let RECALL = 'recall';
|
|
17
|
+
//# sourceMappingURL=mod.js.map
|
package/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GAED,SAAS,WAAW,qBAAoB;AAExC,0CAA0C,GAC1C,OAAO,IAAI,QAAQ,QAAO;AAC1B,OAAO,IAAI,SAAS,SAAQ"}
|
package/mod.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background work an agent does when nobody is asking it anything. A `dream`
|
|
3
|
+
* is a standing intention filed under a project; `recall` is what dreaming
|
|
4
|
+
* consolidates — how many times a memory has been recalled, and when it last
|
|
5
|
+
* was. A `recalled` edge records one such recall, and a `meta` component marks
|
|
6
|
+
* text written for a dream to read later rather than for anyone right now.
|
|
7
|
+
*
|
|
8
|
+
* A dream runs as a @yaks/builders builder: it wears `builder` beside `dream`,
|
|
9
|
+
* its `content` body is the template, and @yaks/builders decides when a session
|
|
10
|
+
* opens on it and keeps what that session answered as its output. This package
|
|
11
|
+
* runs nothing itself.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export { dreamingDoc } from './vocab.js'
|
|
17
|
+
|
|
18
|
+
/** The components this package declares. */
|
|
19
|
+
export let DREAM = 'dream'
|
|
20
|
+
export let RECALL = 'recall'
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaks/dreaming",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.36",
|
|
4
|
+
"homepage": "https://jsr.io/@yaks/dreaming",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./_dist/mod.d.ts",
|
|
9
|
+
"default": "./mod.js"
|
|
10
|
+
},
|
|
11
|
+
"./vocab": {
|
|
12
|
+
"types": "./_dist/vocab.d.ts",
|
|
13
|
+
"default": "./vocab.js"
|
|
14
|
+
},
|
|
15
|
+
"./graph": {
|
|
16
|
+
"types": "./_dist/graph.d.ts",
|
|
17
|
+
"default": "./graph.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@yaks/sql": "0.2.36",
|
|
23
|
+
"@yaks/vocab": "0.2.36"
|
|
24
|
+
},
|
|
25
|
+
"description": "Standing intentions filed under a project, which @yaks/builders builds on a schedule, a record of how often each memory has been recalled, and the `.order=hot` ranking that record decays along.",
|
|
26
|
+
"repository": "https://github.com/yak-sh/yak.git"
|
|
27
|
+
}
|
package/vocab.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The dreaming component declarations alone, exported as
|
|
2
|
+
// `@yaks/dreaming/vocab`. Nothing here touches storage, SQL or any runtime
|
|
3
|
+
// API, so a browser tab that only needs these components loads nothing else.
|
|
4
|
+
import doc from './vocab.json' with {
|
|
5
|
+
type: 'json'
|
|
6
|
+
};
|
|
7
|
+
import manifest from './package.json' with {
|
|
8
|
+
type: 'json'
|
|
9
|
+
};
|
|
10
|
+
/** The dreaming vocabulary, as the document `loadVocab` accepts. */ export let dreamingDoc = doc;
|
|
11
|
+
/** What this package is: its manifest's description, the one place it is
|
|
12
|
+
* written, which a host stamps on each document here. */ export let description = manifest.description;
|
|
13
|
+
/** Every document this plugin declares. */ export let docs = [
|
|
14
|
+
dreamingDoc
|
|
15
|
+
];
|
|
16
|
+
//# sourceMappingURL=vocab.js.map
|
package/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,2EAA2E;AAC3E,6EAA6E;AAG7E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,kEAAkE,GAClE,OAAO,IAAI,cAAwB,IAAe;AAElD;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAY,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:361af1ff-bdfa-4abf-b662-7da1973f275a",
|
|
3
|
+
"$vocabulary": {
|
|
4
|
+
"https://yak.sh/vocab/core": true,
|
|
5
|
+
"https://yak.sh/vocab/id": true,
|
|
6
|
+
"https://yak.sh/vocab/edge": true
|
|
7
|
+
},
|
|
8
|
+
"title": "dreaming",
|
|
9
|
+
"$defs": {
|
|
10
|
+
"dream": {
|
|
11
|
+
"$id": "urn:uuid:1affad8e-c0ed-49b6-bddd-af387520971a",
|
|
12
|
+
"component": true,
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"scope": {
|
|
16
|
+
"$id": "urn:uuid:11f9e56d-0fdb-4b19-98da-dfc9ad9bfde2",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"ref": "project",
|
|
19
|
+
"death": "cascade",
|
|
20
|
+
"description": "the project it is filed under"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"description": "a standing intention filed under a project; it wears @yaks/builders' `builder`, which says when it runs"
|
|
24
|
+
},
|
|
25
|
+
"meta": {
|
|
26
|
+
"$id": "urn:uuid:d2ec8d8a-1d97-483a-80a0-d7fd5fb10f4f",
|
|
27
|
+
"component": true,
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {},
|
|
30
|
+
"description": "a note written in a transcript: never delivered to anyone live, read later by a dream"
|
|
31
|
+
},
|
|
32
|
+
"recall": {
|
|
33
|
+
"$id": "urn:uuid:496b0362-c969-40c8-b126-44903153b798",
|
|
34
|
+
"component": true,
|
|
35
|
+
"journal": false,
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"count": {
|
|
39
|
+
"$id": "urn:uuid:c44bbcfa-2812-4416-bffa-fc9979148280",
|
|
40
|
+
"type": "number",
|
|
41
|
+
"stamped": true,
|
|
42
|
+
"description": "how many times it has been recalled"
|
|
43
|
+
},
|
|
44
|
+
"first_at": {
|
|
45
|
+
"$id": "urn:uuid:b8701e97-a18b-4129-8c6f-a0f5082e433c",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"format": "date-time",
|
|
48
|
+
"stamped": true,
|
|
49
|
+
"description": "when it was first recalled"
|
|
50
|
+
},
|
|
51
|
+
"last_at": {
|
|
52
|
+
"$id": "urn:uuid:67d645ff-7c25-44a6-a395-1a81b8dc2b6b",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"format": "date-time",
|
|
55
|
+
"stamped": true,
|
|
56
|
+
"description": "when it was last recalled"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"description": "how many times an entity has been recalled, and when it last was"
|
|
60
|
+
},
|
|
61
|
+
"recalled": {
|
|
62
|
+
"$id": "urn:uuid:188352d4-f2a0-4617-a622-1a07e6ecf938",
|
|
63
|
+
"component": true,
|
|
64
|
+
"journal": false,
|
|
65
|
+
"type": "object",
|
|
66
|
+
"edge": "recalled",
|
|
67
|
+
"reversed": "recalled by",
|
|
68
|
+
"properties": {
|
|
69
|
+
"source": {
|
|
70
|
+
"$id": "urn:uuid:c5c5d233-0f4c-43ec-ad09-e5d551301338",
|
|
71
|
+
"type": "string",
|
|
72
|
+
"ref": "entry",
|
|
73
|
+
"death": "keep"
|
|
74
|
+
},
|
|
75
|
+
"at": {
|
|
76
|
+
"$id": "urn:uuid:c799521b-9bf3-43d0-8ea5-7de24a013ea1",
|
|
77
|
+
"type": "string",
|
|
78
|
+
"format": "date-time"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"description": "an edge relation: this entry recalled that entity, at this time"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"kinds": {
|
|
85
|
+
"dream": {
|
|
86
|
+
"$id": "urn:uuid:1affad8e-c0ed-49b6-bddd-af387520971a",
|
|
87
|
+
"description": "a standing intention filed under a project; it wears @yaks/builders' `builder`, which says when it runs",
|
|
88
|
+
"with": {
|
|
89
|
+
"builder": true
|
|
90
|
+
},
|
|
91
|
+
"before": [
|
|
92
|
+
"doc"
|
|
93
|
+
],
|
|
94
|
+
"prefix": "Z",
|
|
95
|
+
"examples": [
|
|
96
|
+
{
|
|
97
|
+
"dream": {},
|
|
98
|
+
"builder": {
|
|
99
|
+
"query": ".task !completed"
|
|
100
|
+
},
|
|
101
|
+
"doc": {
|
|
102
|
+
"title": "Tidy the open tasks"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The dreaming component declarations alone, exported as
|
|
2
|
+
// `@yaks/dreaming/vocab`. Nothing here touches storage, SQL or any runtime
|
|
3
|
+
// API, so a browser tab that only needs these components loads nothing else.
|
|
4
|
+
|
|
5
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
6
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
7
|
+
import manifest from './package.json' with { type: 'json' }
|
|
8
|
+
|
|
9
|
+
/** The dreaming vocabulary, as the document `loadVocab` accepts. */
|
|
10
|
+
export let dreamingDoc: VocabDoc = doc as VocabDoc
|
|
11
|
+
|
|
12
|
+
/** What this package is: its manifest's description, the one place it is
|
|
13
|
+
* written, which a host stamps on each document here. */
|
|
14
|
+
export let description: string = manifest.description
|
|
15
|
+
|
|
16
|
+
/** Every document this plugin declares. */
|
|
17
|
+
export let docs: VocabDoc[] = [dreamingDoc]
|