@yaks/topic 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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +256 -2
  3. package/_dist/context.d.ts +74 -0
  4. package/_dist/context.d.ts.map +1 -0
  5. package/_dist/graph.d.ts +5 -0
  6. package/_dist/graph.d.ts.map +1 -0
  7. package/_dist/mod.d.ts +33 -0
  8. package/_dist/mod.d.ts.map +1 -0
  9. package/_dist/share.d.ts +61 -0
  10. package/_dist/share.d.ts.map +1 -0
  11. package/_dist/shelves.d.ts +24 -0
  12. package/_dist/shelves.d.ts.map +1 -0
  13. package/_dist/tools.d.ts +5 -0
  14. package/_dist/tools.d.ts.map +1 -0
  15. package/_dist/topic.d.ts +50 -0
  16. package/_dist/topic.d.ts.map +1 -0
  17. package/_dist/views.d.ts +23 -0
  18. package/_dist/views.d.ts.map +1 -0
  19. package/_dist/vocab.d.ts +6 -0
  20. package/_dist/vocab.d.ts.map +1 -0
  21. package/catalogue.js +155 -0
  22. package/catalogue.js.map +1 -0
  23. package/catalogue.ts +218 -0
  24. package/context.js +289 -0
  25. package/context.js.map +1 -0
  26. package/context.ts +318 -0
  27. package/deno.json +1 -0
  28. package/graph.js +32 -0
  29. package/graph.js.map +1 -0
  30. package/graph.ts +26 -0
  31. package/inspect.js +48 -0
  32. package/inspect.js.map +1 -0
  33. package/inspect.ts +25 -0
  34. package/mod.js +33 -0
  35. package/mod.js.map +1 -0
  36. package/mod.ts +56 -0
  37. package/package.json +50 -4
  38. package/page.js +247 -0
  39. package/page.js.map +1 -0
  40. package/page.ts +297 -0
  41. package/share.js +104 -0
  42. package/share.js.map +1 -0
  43. package/share.ts +115 -0
  44. package/shelves.js +99 -0
  45. package/shelves.js.map +1 -0
  46. package/shelves.ts +93 -0
  47. package/tools.js +114 -0
  48. package/tools.js.map +1 -0
  49. package/tools.ts +122 -0
  50. package/topic.js +97 -0
  51. package/topic.js.map +1 -0
  52. package/topic.ts +128 -0
  53. package/tree.js +77 -0
  54. package/tree.js.map +1 -0
  55. package/tree.ts +93 -0
  56. package/views.js +30 -0
  57. package/views.js.map +1 -0
  58. package/views.ts +26 -0
  59. package/vocab.js +16 -0
  60. package/vocab.js.map +1 -0
  61. package/vocab.json +186 -0
  62. 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,257 @@
1
- # Temporary Holding Version
1
+ # @yaks/topic
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A knowledge graph of topics. A topic is a subject, such as "data model" or
4
+ "testing", and a project is its own topic. A topic belongs to whatever contains
5
+ it: one about a project sits under the project, and one about the world under
6
+ none. Together they form a tree you can open, browse and read, everything known
7
+ about a subject is held under it, and every claim in it leads back to who said
8
+ it.
9
+
10
+ A topic is an entity (a record identified by `entity.eid`) carrying:
11
+
12
+ - `topic{name}`: `name` is its title in lowercase with single spaces, and no two
13
+ topics share one, so a name said twice is one topic. It is a name, not an
14
+ identity: the eid is the entity's own, so any entity may wear `topic`, and a
15
+ project does, to be its own topic.
16
+ - `doc{title, body}` ([@yaks/doc](../doc)), the **cover**: its title and a line
17
+ or two saying what belongs under it, what a reader sees in a list and decides
18
+ by.
19
+ - `content{body}` ([@yaks/tools](../tools)), the **contents**: what is
20
+ understood about the subject, written as one document.
21
+
22
+ Its edges are relations that already exist, never new ones:
23
+
24
+ | Relation | Package | Means |
25
+ | --------------------- | ------------------------- | -------------------------------------------------------------------- |
26
+ | `contains` | [@yaks/task](../task) | what it holds: a subtopic, or any other entity (a memory, a package) |
27
+ | `requires` | [@yaks/task](../task) | a topic to understand first |
28
+ | `reads`, `references` | [@yaks/kernel](../kernel) | related things, listed but not held |
29
+ | `cites{hash}` | [@yaks/kernel](../kernel) | its sources: verbatim words, sessions, entries, memories |
30
+
31
+ Beliefs ([@yaks/memory](../memory)) are about topics (`belief{scope, about}`): a
32
+ memory marks what was said, a belief concludes something from memories and cites
33
+ them, and a topic's contents are written from its beliefs and cite them. So a
34
+ reader goes cover, contents, sources, and down the tree.
35
+
36
+ ## A topic as a session's context
37
+
38
+ A session can be **opened on a topic**: this package adds `topic` to
39
+ [@yaks/session](../session)'s `session`, the topic it was opened on, beside the
40
+ persona it wears. Such a session wears one persona, the **oracle** (`ORACLE`, a
41
+ persona at an eid every graph derives alike), unless whoever opened it named
42
+ another, and each of its asks is told the topic's tree as it reads then,
43
+ compiled into one markdown document after the persona's text (@yaks/harness
44
+ `wear`). No persona is made or kept per topic: the topic tree is the one tree to
45
+ maintain, and the oracle is what every topic session hears.
46
+
47
+ The tree a topic compiles to (`gather` reads it, `compile` writes it):
48
+
49
+ - where it sits: each topic containing it, up to the roots, by its cover;
50
+ - the topic: its cover, its contents, and the `$was` token of its contents, so a
51
+ session rewrites them without reading them again;
52
+ - what it holds, in full, in edge order, as a persona includes what it contains.
53
+ A body over `CUT` characters is cut at a paragraph and names its id for the
54
+ rest, and past `BUDGET` characters in all, the rest are listed;
55
+ - below it: its subtopics as an outline, each with its cover and the titles of
56
+ what it holds, `LEVELS` deep;
57
+ - what to understand first, what is related and its sources, a line each.
58
+
59
+ `compile` is pure, so a tree read elsewhere compiles the same way:
60
+
61
+ ```ts
62
+ import { compile, cut } from '@yaks/topic'
63
+ import { topicDoc } from '@yaks/topic/vocab'
64
+ import { sessionDoc } from '@yaks/session/vocab'
65
+ import { docDoc } from '@yaks/doc/vocab'
66
+ import { loadVocab } from '@yaks/vocab'
67
+ import { equal } from '@yaks/testing'
68
+
69
+ let vocab = loadVocab([docDoc, sessionDoc, topicDoc])
70
+ let said = compile(vocab)({
71
+ topic: {
72
+ entity: { eid: 'q1' },
73
+ topic: { name: 'data model' },
74
+ doc: { title: 'Data model', body: 'How data is shaped.' },
75
+ },
76
+ holds: [{ entity: { eid: 'm1' }, doc: { title: 'Ids', body: 'An eid.' } }],
77
+ path: [],
78
+ below: [],
79
+ needs: [],
80
+ related: [],
81
+ sources: [],
82
+ })
83
+ equal(said.split('\n\n---\n\n').slice(0, 2), [
84
+ '# #q1 Data model\n\nHow data is shaped.\n\n## Contents\n\nNothing is written here yet.',
85
+ '# #m1 Ids\n\nAn eid.\n',
86
+ ])
87
+ equal(cut('one two\n\nthree four', 12), { text: 'one two', left: 12 })
88
+ ```
89
+
90
+ Over a graph, `await gather(g)('Q-9')` reads the tree, or `undefined` where the
91
+ id names no topic.
92
+
93
+ Doors that open one: `yak session new --topic Q-9 "…"` and `session_new` with
94
+ `topic` ([@yaks/harness](../harness)); in a browser, the Ask part of a topic's
95
+ page; and `yak topic read Q-9` prints what such a session is given.
96
+
97
+ ## Install
98
+
99
+ ```sh
100
+ deno add jsr:@yaks/topic
101
+ ```
102
+
103
+ ## Use
104
+
105
+ ```ts
106
+ import { fits, named, overlaps } from '@yaks/topic'
107
+ import { equal } from '@yaks/testing'
108
+
109
+ equal(named(' Data Model '), 'data model')
110
+ equal(overlaps('economic market design', 'market design'), true)
111
+ equal(overlaps('ui design', 'cover design'), false)
112
+ equal(fits('Data Modeling', 'data model'), true)
113
+ ```
114
+
115
+ A topic is **found** by what somebody says (`fits`): each word said starts one
116
+ of the topic's words (its name's, title's and cover's), as it is typed, or
117
+ shares its stem with one, so "data modeling" finds data model and "tests" finds
118
+ testing.
119
+
120
+ ## The tools
121
+
122
+ `@yaks/topic/tools` exports `runs()`, the implementations behind the four tools
123
+ `vocab.json` declares (`yak topic find`, `yak topic new`, `yak topic add`,
124
+ `yak topic read`, and each over `/mcp`):
125
+
126
+ ```sh
127
+ yak topic find model
128
+ yak topic find --near '#c625160bfa'
129
+ yak topic new testing --body 'what a test checks, and how fast a suite runs'
130
+ yak topic add Q-9 M-14942 M-59035
131
+ yak topic add 'Task Graph' D-391
132
+ yak topic add Q-9 M-59035 --drop
133
+ yak topic read Q-9
134
+ ```
135
+
136
+ `topic read` answers the topic tree compiled from one topic, the context a
137
+ session opened on it starts from.
138
+
139
+ `topic find` answers topics whole: those `said` finds (`fits`), ranked by
140
+ meaning to `near` where the server has embeddings, or else in order of name.
141
+
142
+ `topic new` makes a topic from a name and a cover. One name is one topic, so it
143
+ refuses a name that is taken, or whose words hold another topic's or are held by
144
+ them ("economic market design" beside "market design"), and says which topic to
145
+ use. Whoever makes a topic finds first, so a subject already named is reused,
146
+ and the name's unique index refuses the second of two writers that found nothing
147
+ at once. Neither the name nor the cover says a project: what a topic belongs to
148
+ is whatever contains it, so one about a project goes under the project with
149
+ `topic add`.
150
+
151
+ `topic add` puts entities under a topic, a `contains` edge from the topic to
152
+ each, where whoever reads the topic finds them: a memory, a design, a skill, a
153
+ package, somebody's words, a subtopic. Adding one already there changes nothing,
154
+ and `--drop` takes them out. It refuses a topic that is not one, and a topic
155
+ holding itself. A project is its own topic, so a project's id or name places
156
+ things under it.
157
+
158
+ ## The views
159
+
160
+ `@yaks/topic/views` draws the topics wherever the browsing app
161
+ ([@yaks/browse](../browse)) does, in a browser and a terminal alike, as a
162
+ library's catalogue: the shelves on one side, the topic opened on the other.
163
+
164
+ The **shelves** are every topic as a tree: the topics no topic contains at the
165
+ top, each over the topics it contains, each level by title (`shelves`, pure).
166
+ Over them a field finds a topic by what is typed, narrowing the shelves to the
167
+ topics it finds under the topics holding them; Enter opens the first, and Escape
168
+ clears it. What is typed there is the person's draft, through the UX host's
169
+ `drafts` (@yaks/ux).
170
+
171
+ The sidebar offers them as **Topics** (`destinations`), at `/?page=topics`:
172
+ every topic with its cover (`Topics.Page`). A topic opens on its page, the
173
+ `Topic` tab, beside the shelves, titles only, the topic lit and the shelves
174
+ holding it open; stacked, as on a phone, the page comes first. The page alone is
175
+ its `Inspect.Page`, and a card's face (`Card.Topic`):
176
+
177
+ - the head: its title and what contains it, each named from the answer that
178
+ brought it;
179
+ - the cover's words; then a line to ask about it, where the host draws a
180
+ conversation (`Conversation`; browse's chat), whose first message opens a
181
+ session on the topic wearing the oracle; then the contents, as markdown;
182
+ - what it contains, what to understand first, what is related and its sources,
183
+ each in edge order, an ordered list edited in place (@yaks/inspect's `Held`):
184
+ a row dragged between two others is put there, and opens where it stands on
185
+ its title and body;
186
+ - the beliefs about it, newest first, and the archived ones on a press, muted;
187
+ - the comments on it, with a line to write one, where the host draws a thread
188
+ (`Comments`; @yaks/kernel's in browse), each stamped as its writer's;
189
+ - then the facts, links and history any page has.
190
+
191
+ Whatever it holds or cites is drawn by that entity's own renderer, asked for as
192
+ `Topic.List.Tile`: a subtopic as its cover, a belief as what it states
193
+ (@yaks/memory), anything else as it reads in any list.
194
+
195
+ The `Tree` tab draws what a topic contains all the way down, each subtopic's
196
+ holdings nested under it. It walks only into topics, draws a topic met again on
197
+ its own path without walking it, and links to the rest past `DEPTH` levels.
198
+
199
+ ## A topic's share of the week
200
+
201
+ A topic can be given a share: `attended{share}`, the part, 0 to 1, of each
202
+ plan's week (@yaks/model's `rate_limit`) that work for it may use. Work for a
203
+ topic is the session opened on it and every session that one started. Any topic
204
+ can have one, a project as much as a subject.
205
+
206
+ A subtopic's share is part of its parent's, so what a topic keeps is its share
207
+ less the shares of the nearest topics below it that have one. Work for a topic
208
+ with no share is charged to the nearest topic above it that has one, and work
209
+ with none above it was never allotted. Only the share is stored. What a topic
210
+ keeps, and how much of it is used, are read each time: `yak spend show` prints a
211
+ line for each topic with a share ([@yaks/spend](../spend)).
212
+
213
+ A share refuses nothing. A session reads it beside how much of the week is gone
214
+ and paces itself.
215
+
216
+ ```ts
217
+ import { above, holder, kept } from '@yaks/topic/share'
218
+ import { equal } from '@yaks/testing'
219
+
220
+ let shares = {
221
+ share: new Map([['pilots', 0.5], ['grove', 0.25]]),
222
+ up: new Map([['grove', ['pilots']], ['site', ['grove']]]),
223
+ }
224
+ equal(kept(shares).get('pilots'), 0.25)
225
+ equal([holder(shares, 'site'), above(shares, 'grove')], ['grove', 'pilots'])
226
+ ```
227
+
228
+ ## Exports
229
+
230
+ The root exports `topicDoc`, `named` (a title folded to a topic's name), `HOLDS`
231
+ (the relation a topic holds things by, `contains`), `overlaps` (whether two
232
+ names share a subject by their words), `fits` (whether what was said finds a
233
+ topic's words), `about` (a topic's words: name, title and cover), `found` (the
234
+ query that reads every topic), `shelves` and `within` (the topics as a tree, and
235
+ that tree narrowed to what was said), `gather` and `compile` (a topic's tree as
236
+ read, and as the markdown a session opened on it starts from), `cut` (a body cut
237
+ at a paragraph), `ORACLE` (the persona a topic session wears), and the constants
238
+ `TOPIC`, `FIND`, `TOPICS`, `CUT`, `BUDGET`, `LEVELS`, `LINES` and `GIST`.
239
+ `@yaks/topic/vocab` exports `topicDoc` and `docs: [topicDoc]` for schema
240
+ loaders. `@yaks/topic/graph` exports `plugins()`, whose `normalize` hook folds
241
+ every `topic.name` a write carries with `named`, so a name typed in any case or
242
+ spacing, through any door, is the one topic's. `@yaks/topic/share` exports
243
+ `SHARE` (the component's name), `shares` (a graph's shares and how its topics
244
+ nest), `above`, `holder` and `kept`. `@yaks/topic/views` exports
245
+ `inspectViews()`, which loads the shelves, the page, the tree and the tile;
246
+ `tabs`, the two tabs a topic wears; `destinations`, the Topics page the sidebar
247
+ offers; and `icons`, the glyph it wears.
248
+
249
+ ## Compatibility
250
+
251
+ Pure TypeScript with no platform API, so it runs in a browser, on Deno and on
252
+ Node. The tools need a configured graph, and `near` a vector index. The views
253
+ are Preact components a host mounts through @yaks/inspect's contract.
254
+
255
+ ## License
256
+
257
+ Apache-2.0
@@ -0,0 +1,74 @@
1
+ import type { Bundle, Eid, Graph } from "@yaks/graph";
2
+ import type { Vocab } from "@yaks/vocab";
3
+ /** How many characters of one held entity's body are carried; the rest is
4
+ * named, to be read with graph_show. */ export declare let CUT: number;
5
+ /** How many characters of held bodies a topic carries in all; past it, what
6
+ * it holds is listed by id and title. */ export declare let BUDGET: number;
7
+ /** How many levels below the topic its outline goes. */ export declare let LEVELS: number;
8
+ /** How many lines the outline below a topic holds at most. */ export declare let LINES: number;
9
+ /** How many characters of its first line name an entity that has no title. */ export declare let GIST: number;
10
+ /** A topic below the one compiled: what it holds, by title, and the topics
11
+ * below it in turn. */ export type Branch = {
12
+ topic: Bundle;
13
+ holds: Bundle[];
14
+ below: Branch[];
15
+ };
16
+ /** One topic's tree, as read. */ export type Gathered = {
17
+ /** the topic */ topic: Bundle;
18
+ /** the topics containing it, up to the roots, root first */ path: Bundle[];
19
+ /** what it contains that is not a topic, in edge order */ holds: Bundle[];
20
+ /** the topics it contains, each with what lies below it */ below: Branch[];
21
+ /** what to understand first (`requires`) */ needs: Bundle[];
22
+ /** what is related (`reads`, `references`) */ related: Bundle[];
23
+ /** its sources (`cites`) */ sources: Bundle[];
24
+ };
25
+ /**
26
+ * A topic's tree, read out of a graph: where it sits, what it holds, what
27
+ * lies below it, and what it requires, relates to and cites. `undefined` when
28
+ * the eid names no topic, which is the caller's to refuse.
29
+ *
30
+ * ```ts ignore
31
+ * let got = await gather(g)('Q-59416')
32
+ * if (got) console.log(compile(g.vocab)(got))
33
+ * ```
34
+ */ export declare let gather: (g: Graph) => any;
35
+ /** A body cut to at most `at` characters, at the last paragraph (else line)
36
+ * break past half of it, and how many characters were left off. */ export declare let cut: (text: string, at: number) => {
37
+ text: string;
38
+ left: number;
39
+ };
40
+ /**
41
+ * A topic's tree as one markdown document, the context a session opened on it
42
+ * starts from. Takes the loaded vocabulary first, for the ids it names:
43
+ * `compile(vocab)(gathered)`.
44
+ *
45
+ * ```md
46
+ * # Q-1 Data model
47
+ *
48
+ * How data is shaped in the graph.
49
+ *
50
+ * ## Within
51
+ *
52
+ * - Q-2 Architecture: how the system is built
53
+ *
54
+ * ## Contents
55
+ *
56
+ * What is understood about it.
57
+ *
58
+ * $was of its contents: {"content": {"body": "9f86…"}}
59
+ *
60
+ * ---
61
+ *
62
+ * # M-3 Stored state properties are an anti-pattern
63
+ *
64
+ * a held entity's body, in full
65
+ *
66
+ * ---
67
+ *
68
+ * ## Below
69
+ *
70
+ * - Q-4 Identity: ids, names and keys
71
+ * - M-5 Names in any system must always be changeable
72
+ * ```
73
+ */ export declare let compile: (vocab: Vocab) => (got: Gathered) => string;
74
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sources":["../context.ts"],"names":[],"mappings":"AAsBA,cAAc,MAAM,EAAE,GAAG,EAAE,KAAK,2BAAgC;AAKhE,cAAc,KAAK,2BAAgC;AAGnD;sCACsC,GACtC,OAAO,YAAI,YAAU;AAErB;uCACuC,GACvC,OAAO,YAAI,eAAe;AAE1B,sDAAsD,GACtD,OAAO,YAAI,eAAU;AAErB,4DAA4D,GAC5D,OAAO,YAAI,cAAW;AAEtB,4EAA4E,GAC5E,OAAO,YAAI,aAAS;AASpB;qBACqB,GACrB,YAAY;EAAW,OAAO;EAAQ,OAAO;EAAU,OAAO;;AAE9D,+BAA+B,GAC/B,YAAY;EACV,cAAc,GACd,OAAO;EACP,0DAA0D,GAC1D,MAAM;EACN,wDAAwD,GACxD,OAAO;EACP,yDAAyD,GACzD,OAAO;EACP,0CAA0C,GAC1C,OAAO;EACP,4CAA4C,GAC5C,SAAS;EACT,0BAA0B,GAC1B,SAAS;;AAqFX;;;;;;;;;CASC,GACD,OAAO,YAAI,SACR,GAAG,cAoBH;AAOH;iEACiE,GAGjE,OAAO,YAAI,MAAO,MAAM,MAAM,EAAE,IAAI,MAAM;EAAK,MAAM,MAAM;EAAE,MAAM,MAAM;EAQxE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,YAAI,UAAW,OAAO,WAAS,KAAK,aAAa,MAAM,CAyE7D"}
@@ -0,0 +1,5 @@
1
+ import { type Bundle, type Plugin } from "@yaks/graph";
2
+ /** A bundle with its topic's name folded, or as it came. */ export declare let fold: (b: Bundle) => Bundle;
3
+ /** The topic plugin: a name folded on the way in. */ export declare let topics: () => Plugin;
4
+ /** The graph plugins this package contributes. */ export declare let plugins: () => Plugin[];
5
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAMA,SAAS,KAAK,MAAM,EAAmB,KAAK,MAAM,2BAAgC;AAGlF,0DAA0D,GAG1D,OAAO,YAAI,OAAQ,GAAG,WAAS,OAI9B;AAED,mDAAmD,GACnD,OAAO,YAAI,cAAa,OAGtB;AAEF,gDAAgD,GAChD,OAAO,YAAI,eAAc,SAAsB"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @yaks/topic — a knowledge graph of topics. A topic is a subject:
3
+ * `topic{name}` beside `doc{title, body}`, its cover, and `content{body}`,
4
+ * its contents; a project is its own topic, and a topic belongs to whatever
5
+ * contains it. Its edges say what it holds (`contains`: a subtopic, or any
6
+ * other entity), what to understand first (`requires`), what it reads and
7
+ * references, and the sources it cites (`cites{hash}`); those relations are
8
+ * @yaks/task's and @yaks/kernel's, and nothing here copies them.
9
+ *
10
+ * A topic is also a session's context: a session opened on one
11
+ * (`session.topic`) wears the {@link ORACLE} persona and starts from the
12
+ * topic's tree, read by `gather` and written as markdown by `compile`.
13
+ *
14
+ * ```ts
15
+ * import { fits, named, overlaps } from '@yaks/topic'
16
+ *
17
+ * named('Data Model') // 'data model'
18
+ * overlaps('economic market design', 'market design') // true
19
+ * fits('data modeling', 'data model') // true
20
+ * ```
21
+ *
22
+ * A topic can be given a share of each plan's week, `attended{share}`; what
23
+ * it keeps of it under its subtopics' shares is `@yaks/topic/share`.
24
+ *
25
+ * The tools, `topic_find`, `topic_new`, `topic_add` and `topic_read`, are
26
+ * `@yaks/topic/tools`.
27
+ *
28
+ * @module
29
+ */ export { about, FIND, fits, found, HOLDS, named, ORACLE, overlaps, TOPIC, TOPICS } from "./topic.js";
30
+ export { type Branch, BUDGET, compile, CUT, cut, gather, type Gathered, GIST, LEVELS, LINES } from "./context.js";
31
+ export { type Shelf, shelves, within } from "./shelves.js";
32
+ export { topicDoc } from "./vocab.js";
33
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GAED,SACE,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,qBACW;AACnB,SACE,KAAK,MAAM,EACX,MAAM,EACN,OAAO,EACP,GAAG,EACH,GAAG,EACH,MAAM,EACN,KAAK,QAAQ,EACb,IAAI,EACJ,MAAM,EACN,KAAK,uBACc;AACrB,SAAS,KAAK,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAsB;AAC1D,SAAS,QAAQ,qBAAoB"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * A topic's share of the week: `attended{share}`, the part of each plan's
3
+ * week that work for the topic may use. Topics nest, and a subtopic's share
4
+ * is part of its parent's, so what a topic keeps is its share less the shares
5
+ * below it, computed here and never stored. Work for a topic with no share is
6
+ * charged to the nearest topic above it that has one. How much of a share is
7
+ * used is @yaks/spend's to say (`shared`).
8
+ *
9
+ * @module
10
+ */ import type { Eid, Graph } from "@yaks/graph";
11
+ /** The component that gives a topic its share. */ export declare let SHARE: string;
12
+ /** The shares topics have, and how the topics nest. */ export type Shares = {
13
+ /** each topic's share, 0 to 1, where it has one */ share: Map<Eid, number>;
14
+ /** the topics that contain each topic */ up: Map<Eid, Eid[]>;
15
+ };
16
+ /**
17
+ * The nearest topic above `topic` that has a share: of its containers, then
18
+ * of theirs, and of two as near the first by eid.
19
+ *
20
+ * ```ts
21
+ * import { above } from './share.ts'
22
+ * import { equal } from '@yaks/testing'
23
+ *
24
+ * let s = {
25
+ * share: new Map([['pilots', 0.4], ['grove', 0.1]]),
26
+ * up: new Map([['grove', ['pilots']], ['site', ['grove']], ['copy', ['site']]]),
27
+ * }
28
+ * equal([above(s, 'copy'), above(s, 'grove'), above(s, 'pilots')], ['grove', 'pilots', undefined])
29
+ * ```
30
+ */ export declare let above: (s: Shares, topic: Eid) => Eid | undefined;
31
+ /**
32
+ * The topic work for `topic` is charged to: itself where it has a share,
33
+ * else the nearest topic above it that has one. With none above, nothing
34
+ * was allotted for it.
35
+ *
36
+ * ```ts
37
+ * import { holder } from './share.ts'
38
+ * import { equal } from '@yaks/testing'
39
+ *
40
+ * let s = { share: new Map([['pilots', 0.4]]), up: new Map([['grove', ['pilots']]]) }
41
+ * equal([holder(s, 'pilots'), holder(s, 'grove'), holder(s, 'funnel')], ['pilots', 'pilots', undefined])
42
+ * ```
43
+ */ export declare let holder: (s: Shares, topic: Eid) => Eid | undefined;
44
+ /**
45
+ * What each topic with a share keeps: its share less the shares of the
46
+ * nearest topics below it that have one.
47
+ *
48
+ * ```ts
49
+ * import { kept } from './share.ts'
50
+ * import { equal } from '@yaks/testing'
51
+ *
52
+ * let s = {
53
+ * share: new Map([['pilots', 0.5], ['grove', 0.25], ['funnel', 0.125]]),
54
+ * up: new Map([['grove', ['pilots']]]),
55
+ * }
56
+ * equal([...kept(s)], [['pilots', 0.25], ['grove', 0.25], ['funnel', 0.125]])
57
+ * ```
58
+ */ export declare let kept: (s: Shares) => Map<Eid, number>;
59
+ /** The shares a graph's topics have, and the topics that contain each
60
+ * topic. A graph with no share reads no nesting. */ export declare let shares: (g: Graph) => Promise<Shares>;
61
+ //# sourceMappingURL=share.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share.d.ts","sources":["../share.ts"],"names":[],"mappings":"AAAA;;;;;;;;;CASC,GACD,cAAc,GAAG,EAAE,KAAK,2BAAgC;AAIxD,gDAAgD,GAChD,OAAO,YAAI,cAAkB;AAE7B,qDAAqD,GACrD,YAAY;EACV,iDAAiD,GACjD,OAAO,IAAI,KAAK,MAAM;EACtB,uCAAuC,GACvC,IAAI,IAAI,KAAK;;AAGf;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,QAAS,GAAG,QAAQ,OAAO,QAAM,MAAM,SAAS,CAS1D;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SAAU,GAAG,QAAQ,OAAO,QAAM,MAAM,SAAS,CACd;AAE9C;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,OAAQ,GAAG,WAAS,IAAI,KAAK,MAAM,EAO7C;AAED;kDACkD,GAClD,OAAO,YAAI,SAAgB,GAAG,UAAQ,QAAQ,QAqB7C"}